By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,008 Members | 2,963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,008 IT Pros & Developers. It's quick & easy.

SMTP Email not working

P: 3
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="traveldesk@company.com" >
<network host="mail.host.com" port="25" userName="username" password="password" defaultCredentials="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(vFromAddress, vMailId, vSubject, vBody)
Dim Mail As New System.Net.Mail.SmtpClient()
Message.IsBodyHtml = True
Message.ReplyTo = New System.Net.Mail.MailAddress("mai@company.com")
Message.DeliveryNotificationOptions = Net.Mail.DeliveryNotificationOptions.Delay Or Net.Mail.DeliveryNotificationOptions.OnFailure Or Net.Mail.DeliveryNotificationOptions.OnSuccess
If ((Not vAttachFile Is Nothing) AndAlso vAttachFile.Trim().Length > 0) Then
If (System.IO.File.Exists(vAttachFile)) Then Message.Attachments.Add(New System.Net.Mail.Attachment(vAttachFile))
End If

Mail.Send(Message)
End If
Catch ex As Exception
Throw ex
End Try
End Sub
Aug 6 '07 #1
Share this Question
Share on Google+
9 Replies


kenobewan
Expert 2.5K+
P: 4,871
What is the error message and which line? Are you sure this worked perfectly before?
Aug 6 '07 #2

Plater
Expert 5K+
P: 7,872
If you set the isBodyHTML to True, are you supposed to put those <html> tags in there? Or does the mail message add them automatically?
Then you would get like:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  
  4. <html>
  5. <body>
  6. [your text]
  7. </body>
  8. </html>
  9.  
  10. </body>
  11. </html>
  12.  
Aug 6 '07 #3

P: 3
What is the error message and which line? Are you sure this worked perfectly before?
Yeah, this was working properly in XP server with IIS 5.1, but in the production server which is windows 2003 and IIS 6.0, it is not working. And there is no error as such, when i debug the line (mail.send()) is executed with out any error but the receiver is not getting the mail. He/she will get the mail only if the body is a small text (10-12 characters). if there is a <br> tag in the body, again the receiver is not getting the mail.
Aug 6 '07 #4

P: 3
Can anyone help me out ???????.
Aug 7 '07 #5

Floydan
P: 24
Have you checked to see if the IIS server allows 127.0.0.1 to send emails in the SMTP Relay option?
Aug 7 '07 #6

Plater
Expert 5K+
P: 7,872
Theres no issues with it getting flagged junk mail and stuff is there?
Outlook auto-flags anything with a plain IP address as junk mail (for me, I haven't seen how to stop it yet)
Aug 7 '07 #7

Floydan
P: 24
Have you checked to see if the IIS server allows 127.0.0.1 to send emails in the SMTP Relay option?
Setting this option will tell the SMTP server to accept calls from "itself" this was an issue at my former company and something they forgot to check everytime they set up a new server.
Aug 8 '07 #8

P: 15
Setting this option will tell the SMTP server to accept calls from "itself" this was an issue at my former company and something they forgot to check everytime they set up a new server.

You need Microsoft exchange server to relay mails to outside
Aug 8 '07 #9

Plater
Expert 5K+
P: 7,872
You need Microsoft exchange server to relay mails to outside
What is the OP was using an outside mailserver?
I use the mail server that handles my company's email. (We outsource to someone else)
Aug 8 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.