I am sending a email with a HTML body from my VB.NET application using SMTP protocol. I am facing a problem when i send a long HTML text as body. Its working perfectly with small HTML body. But that same long HTML body mail is working perfectly from a XP server and IIS 5.0. If host the same application in IIS 6.0 and windows 2003 server, this problem popsup.
Here is my mail setting section in the web.config
<system.net>
<mailSettings >
<smtp from="traveldes k@company.com" >
<network host="mail.host .com" port="25" userName="usern ame" password="passw ord" defaultCredenti als="true"/>
</smtp>
</mailSettings>
</system.net>
Here is my code for sending the mail.
Public Sub Send()
Try
vBody = "<html> <body>" & vBody & "</body> </html>"
If (vMailId.Trim() .Length > 0) Then
Dim Message As New System.Net.Mail .MailMessage(vF romAddress, vMailId, vSubject, vBody)
Dim Mail As New System.Net.Mail .SmtpClient()
Message.IsBodyH tml = True
Message.ReplyTo = New System.Net.Mail .MailAddress("m ai@company.com" )
Message.Deliver yNotificationOp tions = Net.Mail.Delive ryNotificationO ptions.Delay Or Net.Mail.Delive ryNotificationO ptions.OnFailur e Or Net.Mail.Delive ryNotificationO ptions.OnSucces s
If ((Not vAttachFile Is Nothing) AndAlso vAttachFile.Tri m().Length > 0) Then
If (System.IO.File .Exists(vAttach File)) Then Message.Attachm ents.Add(New System.Net.Mail .Attachment(vAt tachFile))
End If
Mail.Send(Messa ge)
End If
Catch ex As Exception
Throw ex
End Try
End Sub
Here is my mail setting section in the web.config
<system.net>
<mailSettings >
<smtp from="traveldes k@company.com" >
<network host="mail.host .com" port="25" userName="usern ame" password="passw ord" defaultCredenti als="true"/>
</smtp>
</mailSettings>
</system.net>
Here is my code for sending the mail.
Public Sub Send()
Try
vBody = "<html> <body>" & vBody & "</body> </html>"
If (vMailId.Trim() .Length > 0) Then
Dim Message As New System.Net.Mail .MailMessage(vF romAddress, vMailId, vSubject, vBody)
Dim Mail As New System.Net.Mail .SmtpClient()
Message.IsBodyH tml = True
Message.ReplyTo = New System.Net.Mail .MailAddress("m ai@company.com" )
Message.Deliver yNotificationOp tions = Net.Mail.Delive ryNotificationO ptions.Delay Or Net.Mail.Delive ryNotificationO ptions.OnFailur e Or Net.Mail.Delive ryNotificationO ptions.OnSucces s
If ((Not vAttachFile Is Nothing) AndAlso vAttachFile.Tri m().Length > 0) Then
If (System.IO.File .Exists(vAttach File)) Then Message.Attachm ents.Add(New System.Net.Mail .Attachment(vAt tachFile))
End If
Mail.Send(Messa ge)
End If
Catch ex As Exception
Throw ex
End Try
End Sub
Comment