You see: three people say that your code is fine, so the reason should be outside this code. By some reason,
this method itself could be called twice.
Do the following: run it under debugger. Set a break point at the very beginning of the method
sendCancelAppointmentEmail
. When executions comes to the break point, open the Debug window "Call stack" to see where the call comes from.
Alternatively, use
System.Diagnostics.EventLog
to write log information to the system log. To look at the stack, the classes
System.Diagnostics.StackTrace
and
System.Diagnostics.StackFrame
to format the stack data as some text and save this diagnostic information to the system log which you can read later.
Please see MSDN help and code samples:
http://msdn.microsoft.com/en-us/library/system.diagnostics.stacktrace.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.stackframe.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx[
^].
For the advanced usage of
EventLog
, please see my past solutions:
How to create event log under a folder[
^],
MsBuild OutPut to the TextBox on the fly in Windows Application[
^].
If you use these technique (which you will need to master sooner or later anyway, especially the Debugger), you will be able to find ends in no time.
Good luck,
—SA