SMTP Email not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SREEDEV
    New Member
    • Aug 2007
    • 3

    SMTP Email not working

    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
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    What is the error message and which line? Are you sure this worked perfectly before?

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      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:
      [code=html]
      <html>
      <body>

      <html>
      <body>
      [your text]
      </body>
      </html>

      </body>
      </html>
      [/code]

      Comment

      • SREEDEV
        New Member
        • Aug 2007
        • 3

        #4
        Originally posted by kenobewan
        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.

        Comment

        • SREEDEV
          New Member
          • Aug 2007
          • 3

          #5
          Can anyone help me out ???????.

          Comment

          • Floydan
            New Member
            • Aug 2007
            • 24

            #6
            Have you checked to see if the IIS server allows 127.0.0.1 to send emails in the SMTP Relay option?

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              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)

              Comment

              • Floydan
                New Member
                • Aug 2007
                • 24

                #8
                Originally posted by Floydan
                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.

                Comment

                • renjucool
                  New Member
                  • Jun 2007
                  • 15

                  #9
                  Originally posted by Floydan
                  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

                  Comment

                  • Plater
                    Recognized Expert Expert
                    • Apr 2007
                    • 7872

                    #10
                    Originally posted by renjucool
                    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)

                    Comment

                    Working...