Hi,
I am trying to send a long email message containing a disclaimer to users using EWS 2.0 asp.net code. This is a work project. The message has about 80 to 100 lines of text. When I try to send to either gmail or hotmail, the message never gets delivered.
Only when I trim the text to about two lines of text or less, then it works and is delivered. To test this, I sent the same email message of 80-100 lines of text via my Outlook client at work to gmail. This time it went through. What could be in my code that is making this happen?
I even stripped away all style headings and tags and left only plain text and still same issue.
I also tried changing from BodyType.Html to text, and still same issue. I then tried to add the text inline in the message body, same issue again.
I also used my Exchange SMTP relay to send w/o EWS and still the same.
Again, the email works and goes through only when the message is short about 2 lines or less.
Please help. Below is my code:
Dim reader As New StreamReader(Server.MapPath("~/Form_Emp.html"))
Dim readFile As String = reader.ReadToEnd()
Dim myString As String = ""
myString = readFile
myString = myString.Replace("$$User$$", txtFnameH.Value + " " + txtLnameH.Value)
myString = myString.Replace("$$UserName$$", txtUsername.Text)
myString = myString.Replace("$$CompanyName$$", lblDepH.Value)
myString = myString.Replace("$$DateTime$$", DateTime.Now.ToString)
Dim service As ExchangeService = CreateConnection("https://****.asmx")
Dim msg As EmailMessage = New EmailMessage(service)
msg.ToRecipients.Add(New EmailAddress(txtCEmailH.Value))
msg.ToRecipients.Add(New EmailAddress(txtEmailH.Value))
msg.CcRecipients.Add(New EmailAddress(innerEmail.text))
msg.Subject = "Receipt"
msg.Body = New MessageBody(BodyType.HTML, myString.ToString())
msg.Send()