Cannot send email from

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.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

mdebeerAuthor Commented:
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.
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

mdebeerAuthor Commented:
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.
mdebeerAuthor Commented:
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?
Post a request Community Support asking for a moderator to perform that task for you.


Points are not important, but the Grade is :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.