Any help would be greatly appreciated.
Private Sub sendmail()Dim Message1 As MailMessage = New MailMessage
Dim Message2 As MailMessage = New MailMessage
Dim strTo As String = "email@dotnet.itags.org.email.com"
Dim strTo2 As String = "email2@dotnet.itags.org.email.com"
Dim strBody As String
Dim EmailFile As StringSmtpMail.SmtpServer = ConfigurationSettings.AppSettings("SMTPServer")
Message1.From = ConfigurationSettings.AppSettings("EmailFrom")
Message1.Subject = ConfigurationSettings.AppSettings("EmailSubject")
Message2.From = ConfigurationSettings.AppSettings("EmailFrom")
Message2.Subject = ConfigurationSettings.AppSettings("EmailSubjectInternal")Select Case ddlAttendee.SelectedValue
Case "Exhibitor"
EmailFile = "EMAIL-EXHIBITOR.htm"
Case "Reseller"
EmailFile = "EMAIL-RESELLER.htm"
Case "User with Maintenance"
EmailFile = "EMAIL-USER.htm"
Case "User without Maintenance"
EmailFile = "EMAIL-USER.htm"
Case "Potential User"
EmailFile = "EMAIL-OTHER.htm"
Case "Other"
EmailFile = "EMAIL-OTHER.htm"
Case "Potential Reseller"
EmailFile = "EMAIL-OTHER.htm"End Select
Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader(HttpContext.Current.Server.MapPath("") + "\" + EmailFile)
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
Message1.Body += line
Loop Until line Is Nothing
sr.Close()Message1.Body = Message1.Body.Replace("[firstname]", tbFirstName.Text.Trim())
Message1.To = tbEmail.Text
Message1.BodyFormat = MailFormat.Html'Message2 code
'strSubject = "Registration: " + ddlAttendee.SelectedValue.ToUpper
Select Case ddlAttendee.SelectedValue
Case "User with Maintenance"
Message2.To = strTo2
Case "User without Maintenance"
Message2.To = strTo2
Case "Reseller"
Message2.To = strTo2
Case Else
Message2.To = strTo
End Select
'Message2.To = strTo
Message2.Body = strBody
Message2.BodyFormat = MailFormat.Text
strBody = "Registered for conference as attendee type " & ddlAttendee.SelectedValue.ToUpper & "." & vbCrLf
strBody += "ACCTID: " & tbAcctID.Text & vbCrLf
strBody += "PO Number: " & tbPONum.Text & vbCrLf
strBody += "Company: " & tbCompany.Text & vbCrLf
strBody += "Name: " & tbFirstName.Text & " " & tbLastName.Text & vbCrLf
strBody += "Title: " & tbTitle.Text & vbCrLf
strBody += "Address: " & tbAddress.Text & vbCrLf
strBody += "City ST: " & tbCity.Text & " , " & ddlStates.SelectedValue + " " & tbZip.Text & vbCrLf
strBody += "Country: " & ddlCountries.SelectedValue & vbCrLf
strBody += "Phone: " & tbPhone.Text & vbCrLf
strBody += "Email: " & tbEmail.Text
'End message 2 codeSmtpMail.Send(Message1)
SmtpMail.Send(Message2)
Catch ex As Exception
End TryEnd Sub
With this code the message1 gets sent fine w/o any problems however when message2 is sent the body is always missing even though strBody returns the correct value.
TIA,
StueStue,
Looks to me like you just need to move the strBody definition up above your assignment to the message body. At the time you are assigning the body, it is an empty string .. then you are forming the strBody after you have already assigned an empty string to the message
HTH,
Mike
Thanks Mike. Sometimes you just need another pair of eyes. Cant believe i missed that. O well. Thanks so much for your help.
Stue
0 comments:
Post a Comment