Cannot send email from asp.net

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:

          Try
                Dim EmailMsg As MailMessage = New MailMessage

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

                    .Subject = sSubject
                    .Body = sBody
                    .Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 366)
                    '.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2)
                    .Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
                    .Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "myUsername")
                    .Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "myPassword")

                End With
                SmtpMail.SmtpServer = sEmailServer
                SmtpMail.Send(EmailMsg)
            Catch
                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.

mdebeerAsked:
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.

tusharashahCommented:
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.

-tushar
0
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.
0
nauman_ahmedCommented:
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 (127.0.0.1) to relay mails.

Best, Nauman.
0

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.
0
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?
0
tusharashahCommented:
Post a request Community Support asking for a moderator to perform that task for you.
   http://www.experts-exchange.com/Community_Support/

-tushar

Points are not important, but the Grade is :)
0
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
ASP.NET

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.