Emails sent by C# code ending up in junk mail

Posted on 2009-12-21
Last Modified: 2012-05-08
USING windows 2003 SBS and in C#

i am using this code to send email to different users "within" the Co. using the code below, the problem is almost all the time the emails are ending up in users JUNK mail !!! some even changed in Outlook and mark as not junk but again it marks it in junk, is there anyway i can mark this in server to be NOT junk? so regardless of what user does it ends up in their inbox?


MailMessage mail2 = new MailMessage();
                mail2.To = (Email_From);
                mail2.From = ("");
                mail2.Subject = "your comments has been Published!";
                mail2.Body = "To view the comment click here: http://co/marketing/m2Display.aspx?ID=" + comID;
                SmtpMail.SmtpServer = "";

Open in new window

Question by:Raul77
    LVL 5

    Expert Comment

    LVL 5

    Expert Comment

    note that when adding the html to the mail he uses this method
    System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(BodyText, null, text/html);

    Open in new window

    LVL 11

    Expert Comment

    some quick info based on my own experience and dealing with ISPs:
    -make sure your mailfrom is actually a valid address
    -include a text version to your html email
    -avoid strong punctuation in your subjects ("!!!" is a good wayt to the spam box)

    run a spam assassin test on your generated emails to make sure there's nothing you overlooked (you can use this tool for instance):
    LVL 12

    Expert Comment

    While I was dealing with my code, I had used a similar line as follows:
    objEmail.Priority = MailPriority.High;

    and I don't have any problem but e.g. I had hesitated using strong punc. as lenordiste advices.
    and thanks for the link, gemailj. I really love EE:D

    Best regards.
    LVL 29

    Accepted Solution


    My suggestion :
       use the Namespace , this is feacture of 2.0
       this is the System.Web.mail Namespace is 1.1

    More Info

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Email Body 4 31
    Xerox Work Centre 7556 scan to email setup 2 17
    401 - Error 6 11
    EXCH2013 Migration tasks 6 19
    Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
    Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
    In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
    To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now