Sending Email using System.Net.Mail

Posted on 2008-11-07
Medium Priority
Last Modified: 2013-11-30
I have some code that sends an activation code to a user when they sign up for a service.  Some people are not getting the email at all, even when they check their spam/bulk folder.  After reviewing the mail server logs, ALL the emails were successfully sent via the SMTP service but some are just not being delivered.

Could the email provider be flagging this email  as spam?  Is there anything I can do to prevent this?
Dim strMailSubject As String
        Dim strMailBody As String
        strMailSubject = "Welcome"
        Dim ToAddress As String = txtEmail.Text.Trim
        Dim mm As New MailMessage("noreply@-------.com", ToAddress)
        'Dim mm As New MailMessage(ToAddress, ToAddress)
            mm.Subject = strMailSubject
            strMailBody = "Dear " & Trim(lblFName.Text) & ","
            strMailBody = strMailBody & "<BR><BR>Thank you for registering. To complete your registration, please follow the link below or just enter <b>" & lblActivationCode.Text & " </b>in the activate account form"
            strMailBody = strMailBody & "<br><br>" & "<a href='http://" & Request.Url.Host & Request.ApplicationPath & "/Verify.aspx?UserID=" & sUserID & "&ActivationCode=" & lblActivationCode.Text & " '>" & "http://" & Request.Url.Host & Request.ApplicationPath & "/Verify.aspx?UserID=" & sUserID & "&ActivationCode=" & lblActivationCode.Text & "</a>"
            mm.Body = strMailBody
            mm.IsBodyHtml = True
            Dim smtp As New SmtpClient
            lblError.Visible = False
            pnlSucess.visible = True
        Catch ex As Exception
            Me.pnlError.Visible = True
            lblError.Visible = True
            lblError.Text = "<li>" & ex.ToString & "</li>"
            lblError.Text = lblError.Text & "<li>We are currently having trouble processing your email. Please check that your email address is correct. If problem persists, please try again at a later time.</li>"
        End Try

Open in new window

Question by:Paulconsulting
  • 3
  • 2

Expert Comment

ID: 22906850
If the email is successfully sent out by your SMTP server then the problem is not on your side.  The recipient server may be flagging it as spam.  You will have to contact the Admin on the recipient side to track down why the email was not delivered.  If this problem happens often you may want to check your DNS settings and verify your domain/smtp server is not on any black lists.

try these sites: http://www.mxtoolbox.com/blacklists.aspx

LVL 22

Expert Comment

ID: 22906901
>>>Could the email provider be flagging this email  as spam?
Very likely.
>>>Is there anything I can do to prevent this?
Yes, but not much.
"Welcome" is not a very good subject and might be caught as a spam. Try something like "Activation code for your registration". Bottom line: be more specific and more informative, so it will have more chances to pass the spam filter.

Author Comment

ID: 22906934
Thanks, I ran the mail server IP and domain name with those tools you suggested and everything checked out ok, any other suggestions? My co-worker suggested researching email headers.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 22906955
Thanks for the suggestion prairiedog, I will give that a try.
LVL 22

Accepted Solution

prairiedog earned 1500 total points
ID: 22906989
Two other things I can think of is to format your email in a professional way and to inform users to add your email address to their address book.
Researching email header might help as well, but I don't know much about it.

Author Closing Comment

ID: 31514420
After changing the body content and subject, adding a couple of email headers and adding a true "from" address we passed the spam filter

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month16 days, 16 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question