Dave Burke - Freelance .NET Developer specializing in Online Communities

A freelance .NET Developer

SMTP Relaying with .NET 1.1

I've been wrestling with relaying .NET STMP messages beyond our local domain since around 3:00 this afternoon.  It's now around 5:30.  I know, it's a Friday, but darn it, when something doesn't work on one of my servers--whether that particular something is in use or not (and this happens to be not in use)--it bugs me and has to be fixed.

We all have CDO email procs and sometimes need to send to non-domain addresses.  My classic ASP CDO procs worked fine, and am quite certain my .NET 1.0 CDO proces did, but not .NET 1.1.  I knew it had something to do with .NET security, and tried impersonation, changing the username to SYSTEM in the machine.config, adding ASPNET to the SMTP admin group, etc.  Then I found the Golden Google Egg below.  

SmtpMail.SmtpServer = ""; // I had it pointing to the exchange server...

It makes perfect sense now.  You must use LOCALHOST as your smtpserver and let IT do the forwarding for you.

Ahhh, yes.  Now I can relax and enjoy my weekend.

Thank you Charles Fineblum!

From: Charles Fineblum (charle1@comcast.net)
Subject: Re: SMTP error: Could not access 'CDO.Message' object
Newsgroups: microsoft.public.dotnet.languages.csharp
Date: 2003-08-18 11:39:20 PST

Hi Chad:

"You need to use localhost and set the forwarding of your local SMTP server to your main mail router server"

By setting SmtpMail.SmtpServer = "", it should use local smtp server. How do I set forwarding to main mail server? I don't see this setting in SMTP props. I also tried adding the ASP.net account in security tab of SMTP prop, but still same error.

Thanks,
Charlie

Comments

Brian Desmond said:

I fail to see why this is required. So long as the SMTP virtual server on your Exchange box is configured to allow connections & relaying from the web server's IP, and it allows anonymous authentication, you're good to go. Check the authentication tab of the SMTP virtual server's properties. SMTP on Exchange is IIS.
# August 31, 2003 1:42 AM

Dave Burke said:

This is interesting, Brian. Thanks. My network admin partner handles configuration of the Exchange server and steps in with local server issues, but I will pass this along.
# August 31, 2003 9:51 AM

Steffen Grünwald said:

I´m glad to found this article. I read the SmtpServer from the Web.config file and set it there to "" (string.Empty) and it works fine.

Thanks a lot

Steffen

# November 25, 2003 4:18 AM

Paul B said:

I have an issue where I have IIS set up locally on my machine. I can send an email out via an exe. The issue occurs when I try to run the same code set though an ASP.NET project. It bombs out with the same error as above, even though I set the SMTP server to localhost. Any ideas?
# December 12, 2003 1:37 PM

Vlad said:

I got it working but. In my code I don't specify smtp server.

So I don't know which server its using behind the scene. How can I find out and where this configuration is? Is this a CDO configuration?

Many thanks!

                         MailMessage msgMail = new MailMessage();

msgMail.To = toperson;

msgMail.From = fromperson;

msgMail.Subject = emailsubject;

msgMail.BodyFormat = MailFormat.Html;

msgMail.Body = emailbody;

SmtpMail.Send(msgMail);

# November 10, 2008 12:39 PM

Hedy said:

Hi. I used to believe that marriage would diminish me, reduce my options. That you had to be someone less to live with someone else when, of course, you have to be someone more. Help me! Please help find sites for: Tax cut turbo. I found only this - <a href="turbo-tax.biz/.../">becu turbo tax</a>. Turbo tax, the training of this history is actual strategy, likely the strength of trim, intelligent or original scientific club. There are little initial temperatures that can accomplish engine of a life, turbo tax. With love :-(, Hedy from South.

# March 27, 2010 4:06 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)