Cannot send email from

Posted on 2004-11-10
Last Modified: 2008-02-26
I'm trying to send email from an ASP.NET app and I can do it when I run the app from my desktop machine but it does nothing when I deploy to the production server.  I'm running the Merak Email server on production.  My code is:

                Dim EmailMsg As MailMessage = New MailMessage

                With EmailMsg
                    .To = sTo
                    .Cc = sFrom
                    .Bcc = sCC
                    .From = sFrom

                    .Subject = sSubject
                    .Body = sBody
                    .Fields.Add("", 366)
                    '.Fields.Add("", 2)
                    .Fields.Add("", "1")
                    .Fields.Add("", "myUsername")
                    .Fields.Add("", "myPassword")

                End With
                SmtpMail.SmtpServer = sEmailServer
                sError = Err.Description
            End Try

I don't get an email message nor any entry in the SMTP server log that indicates it attempted to send a message.  Obviously there is something on my dev machine that is missing from production but I don't know what.

Question by:mdebeer
    LVL 18

    Assisted Solution

    Are you printing sError message anywhere? Check out if you're getting any error in there.

    The onlything that you might be checking for is your sEmailServer. Make sure it's configured right and myUserName have proper access on that server.


    Author Comment

    Not printing error message but I will do that.

    The code runs find when I run it on my desktop so I know that the username, password, etc. are correct.  It's the same code and it successfully sends an email from that email server if I run it on my desktop.  It just won't run when deployed to the server.
    LVL 25

    Accepted Solution

    ASP.NET needs that the relay option for the local server is set to permitted. Make sure that in the SMTP server properties, you have given rights to localhost ( to relay mails.

    Best, Nauman.

    Author Comment

    I checked the relay option and it was set to allow localhost.  After further investigation it looks like it was a problem with cookies that was preventing the app from ever firing the email code when running on the production box.  Once I fixed the cookie problem the email functioned as expected.

    Thanks for your help.

    Author Comment

    I want to give you guys some points for your responses but the full 500 probably is too much since I resolved it on my own.  Don't know how to assign split and assign less than 500.  Do you guys?
    LVL 18

    Expert Comment

    Post a request Community Support asking for a moderator to perform that task for you.


    Points are not important, but the Grade is :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    761 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

    10 Experts available now in Live!

    Get 1:1 Help Now