C
chuckdfoster
When using this bit of code, it sends two emails most of the time.
Sometimes it doesn't send two, but most of the time it does. I put the
system time (Now) in the Subject and each email has a different time by a
minute or so. I also tried to count the number of emails it is sending by
using the intEmail = intEmail + 1, but the number is always 1.Could anyone
tell me why this is happening or give me advice on how to change it. Thanks
in advance. Help is always greatly appreciated.
If Session("email") <> "" Then
intEmail = intEmail + 1
Dim strBody, strSubject as String
Dim email as New System.Web.Mail.MailMessage
strSubject = "Class Registration Confirmation" & " - " & Now & " - Email
#" & intEmail
strBody = Session("fname") & " " & Session("lname") & ", " & vbcrlf & _
"You registered for the following class." & vbcrlf & _
"Class Name: " & strClass & vbcrlf _
"Class Date: " & dtClass.DayOfWeek.ToString & ", " &
dtClass.ToShortDateString & vbcrlf & _
"Class Length: " & strLength
email.To = Session("email")
email.From = ConfigurationSettings.AppSettings("AdminEmail")
email.BodyFormat = Web.Mail.MailFormat.Text
System.Web.Mail.SmtpMail.SmtpServer =
ConfigurationSettings.AppSettings("MailServer")
System.Web.Mail.SmtpMail.Send(email)
End If
Sometimes it doesn't send two, but most of the time it does. I put the
system time (Now) in the Subject and each email has a different time by a
minute or so. I also tried to count the number of emails it is sending by
using the intEmail = intEmail + 1, but the number is always 1.Could anyone
tell me why this is happening or give me advice on how to change it. Thanks
in advance. Help is always greatly appreciated.
If Session("email") <> "" Then
intEmail = intEmail + 1
Dim strBody, strSubject as String
Dim email as New System.Web.Mail.MailMessage
strSubject = "Class Registration Confirmation" & " - " & Now & " - Email
#" & intEmail
strBody = Session("fname") & " " & Session("lname") & ", " & vbcrlf & _
"You registered for the following class." & vbcrlf & _
"Class Name: " & strClass & vbcrlf _
"Class Date: " & dtClass.DayOfWeek.ToString & ", " &
dtClass.ToShortDateString & vbcrlf & _
"Class Length: " & strLength
email.To = Session("email")
email.From = ConfigurationSettings.AppSettings("AdminEmail")
email.BodyFormat = Web.Mail.MailFormat.Text
System.Web.Mail.SmtpMail.SmtpServer =
ConfigurationSettings.AppSettings("MailServer")
System.Web.Mail.SmtpMail.Send(email)
End If