Send email via external SMTP Server

Discussion in 'ASP .Net' started by =?Utf-8?B?QW5kcmVhcw==?=, Jan 14, 2005.

  1. I am working with three computers, my developing computer, a Web Server and a
    Mail Server (Exchange).

    I am trying to send a email from the Web Server via the Mail Server to a
    valid email address with this code:

    MailMessage msgMail = new MailMessage();
    msgMail.To = "";
    msgMail.From = "";
    msgMail.Subject = "Mail Example Subject";
    msgMail.Body = "MAIL EXAMPLE BODY";
    SmtpMail.SmtpServer = "[Server Name]";
    SmtpMail.Send(msgMail);

    Which does not work.

    My biggest problem is that everything works perfectly on my developing
    computer when I try to send mail via the Mail Server with the same code.

    Why can't I send mail from the Web Server?
     
    =?Utf-8?B?QW5kcmVhcw==?=, Jan 14, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?QW5kcmVhcw==?=

    Willie Guest

    System.Web.Mail use CDO. The CDO dll (cdo.dll, cdont.dll or cdoex.dll, I can't remember which one .NET use) is probably installed on you dev box, but not on the web server.

    If this does not work catch the exception and check the InnerException for a more detailed message why it failed.

    Willie

    nntp://news.microsoft.com/microsoft.public.dotnet.framework.aspnet/<>

    I am working with three computers, my developing computer, a Web Server and a
    Mail Server (Exchange).

    I am trying to send a email from the Web Server via the Mail Server to a
    valid email address with this code:

    MailMessage msgMail = new MailMessage();
    msgMail.To = "";
    msgMail.From = "";
    msgMail.Subject = "Mail Example Subject";
    msgMail.Body = "MAIL EXAMPLE BODY";
    SmtpMail.SmtpServer = "[Server Name]";
    SmtpMail.Send(msgMail);

    Which does not work.

    My biggest problem is that everything works perfectly on my developing
    computer when I try to send mail via the Mail Server with the same code.

    Why can't I send mail from the Web Server?


    [microsoft.public.dotnet.framework.aspnet]
     
    Willie, Jan 14, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?QW5kcmVhcw==?=

    Jim Lawton Guest

    On Fri, 14 Jan 2005 02:23:01 -0800, "Andreas"
    <> wrote:

    >I am working with three computers, my developing computer, a Web Server and a
    >Mail Server (Exchange).
    >
    >I am trying to send a email from the Web Server via the Mail Server to a
    >valid email address with this code:
    >
    >MailMessage msgMail = new MailMessage();
    >msgMail.To = "";
    >msgMail.From = "";
    >msgMail.Subject = "Mail Example Subject";
    >msgMail.Body = "MAIL EXAMPLE BODY";
    >SmtpMail.SmtpServer = "[Server Name]";
    >SmtpMail.Send(msgMail);
    >
    >Which does not work.


    exception? no mail in queue? something else?

    I've had trouble with SMTP and my local machine firewall - symptom was mail
    sitting in the queue...

    J

    >
    >My biggest problem is that everything works perfectly on my developing
    >computer when I try to send mail via the Mail Server with the same code.
    >
    >Why can't I send mail from the Web Server?
     
    Jim Lawton, Jan 14, 2005
    #3
  4. Thanks for the reply!

    I still have the same problem and I have found out that I have these DLL's
    installed:

    I have on the win2003 Web Server:
    cdosys.dll
    mapi32.dll

    I do NOT have on the win2003 Web Server
    cdonts.dll
    cdo.dll
    cdoex.dll

    ---------------------------------------

    I have in my XP dev. computer:
    cdo.dll
    cdosys.dll
    mapi32.dll

    I do NOT have in my XP dev. computer:
    cdonts.dll
    cdoex.dll

    I an trying to catch the expection but nothing is being thrown...

    / Andreas
     
    =?Utf-8?B?QW5kcmVhcw==?=, Jan 17, 2005
    #4
  5. Thank you very much!

    Everything works perfectly now!

    /Andreas


    "Juan T. Llibre" wrote:

    > Hi, Andreas.
    >
    > Windows 2003 doesn't use CDONTS.
    >
    > It uses System.Web.Mail ( which uses cdosys )
    > for .Net apps.
    >
    > See
    > http://support.microsoft.com/default.aspx?scid=kb;en-us;315197&FR=1&PA=1&SD=HSCH
    >
    > You might want to test your capacity to send email
    > using the CDO Object in W2K3 ( CDOSYS )
    > by modifying the attached .vbs script and running it.
    >
    > The script is available online at Microsoft at
    > http://support.microsoft.com/kb/286431?FR=1
    >
    > You can download it from there, or use the attached file.
    > They're the same file.
    >
    > I added a .txt extension in case the .vbs extension
    > is blocked by your client email program or ISP.
    >
    > You'll need to erase the ".txt" part of
    > the filename so it can run as a .vbs script.
    >
    > You can edit it by highlighting the .vbs file
    > right-clicking it, and selecting "Edit" from the menu.
    >
    > Then, all you need to change is the name of the remote smtp
    > server's name, the "To:" address and the "From:" address.
    >
    > Place the modified file in any directory ( I used the "temp" dir )
    > and double-click the vbs file from within Windows Explorer.
    >
    > If your system is configured correctly, the CDOSYS mail
    > will be sent and you should receive in a very short time.
    >
    > There's several reasons why you might not
    > be being allowed to send CDOSYS mail.
    >
    > The most common one is that the remote smtp server
    > requires authentication. i.e., that you might not have
    > sufficient permissions to send mail through that server.
    >
    > Many companies require authentication because if they
    > ran open relay smtp servers, they'd be liable for all SPAM
    > mail sent through their smtp server, not to mention that the
    > bandwidht consumed would cost a small fortune
    > ( maybe even a large fortune ) when spammers find out
    > that they can send mail through an open relay smtp server.
    >
    > Another very common situation is that your ISP
    > is blocking packets on the port you need to send mail.
    >
    > ( Again, Many ISPs don't want the possibility of their clients
    > unwittingly serving as relay servers for spammers. )
    >
    > Running this test will at least enable you to know
    > whether your system is configured to send email
    > using CDOSYS, and whether your ISP's configuration
    > allows mail to be sent through their smtp server.
    >
    > Then we could look for the reasons why
    > it's not working from your ASP.NET app.
    >
    > Let us know how it goes.
    >
    >
    >
    > Juan T. Llibre
    > ASP.NET MVP
    > ===========
    > "Andreas" <> wrote in message
    > news:...
    > > Thanks for the reply!
    > >
    > > I still have the same problem and I have found out that I have these DLL's
    > > installed:
    > >
    > > I have on the win2003 Web Server:
    > > cdosys.dll
    > > mapi32.dll
    > >
    > > I do NOT have on the win2003 Web Server
    > > cdonts.dll
    > > cdo.dll
    > > cdoex.dll
    > >
    > > ---------------------------------------
    > >
    > > I have in my XP dev. computer:
    > > cdo.dll
    > > cdosys.dll
    > > mapi32.dll
    > >
    > > I do NOT have in my XP dev. computer:
    > > cdonts.dll
    > > cdoex.dll
    > >
    > > I an trying to catch the expection but nothing is being thrown...
    > >
    > > / Andreas

    >
    >
    >
     
    =?Utf-8?B?QW5kcmVhcw==?=, Jan 18, 2005
    #5
  6. Glad that got you on the right track, Andreas.



    Juan T. Llibre
    ASP.NET MVP
    ===========
    "Andreas" <> wrote in message
    news:...
    > Thank you very much!
    >
    > Everything works perfectly now!
    >
    > /Andreas
    >
    >
    > "Juan T. Llibre" wrote:
    >
    >> Hi, Andreas.
    >>
    >> Windows 2003 doesn't use CDONTS.
    >>
    >> It uses System.Web.Mail ( which uses cdosys )
    >> for .Net apps.
    >>
    >> See
    >> http://support.microsoft.com/default.aspx?scid=kb;en-us;315197&FR=1&PA=1&SD=HSCH
    >>
    >> You might want to test your capacity to send email
    >> using the CDO Object in W2K3 ( CDOSYS )
    >> by modifying the attached .vbs script and running it.
    >>
    >> The script is available online at Microsoft at
    >> http://support.microsoft.com/kb/286431?FR=1
    >>
    >> You can download it from there, or use the attached file.
    >> They're the same file.
    >>
    >> I added a .txt extension in case the .vbs extension
    >> is blocked by your client email program or ISP.
    >>
    >> You'll need to erase the ".txt" part of
    >> the filename so it can run as a .vbs script.
    >>
    >> You can edit it by highlighting the .vbs file
    >> right-clicking it, and selecting "Edit" from the menu.
    >>
    >> Then, all you need to change is the name of the remote smtp
    >> server's name, the "To:" address and the "From:" address.
    >>
    >> Place the modified file in any directory ( I used the "temp" dir )
    >> and double-click the vbs file from within Windows Explorer.
    >>
    >> If your system is configured correctly, the CDOSYS mail
    >> will be sent and you should receive in a very short time.
    >>
    >> There's several reasons why you might not
    >> be being allowed to send CDOSYS mail.
    >>
    >> The most common one is that the remote smtp server
    >> requires authentication. i.e., that you might not have
    >> sufficient permissions to send mail through that server.
    >>
    >> Many companies require authentication because if they
    >> ran open relay smtp servers, they'd be liable for all SPAM
    >> mail sent through their smtp server, not to mention that the
    >> bandwidht consumed would cost a small fortune
    >> ( maybe even a large fortune ) when spammers find out
    >> that they can send mail through an open relay smtp server.
    >>
    >> Another very common situation is that your ISP
    >> is blocking packets on the port you need to send mail.
    >>
    >> ( Again, Many ISPs don't want the possibility of their clients
    >> unwittingly serving as relay servers for spammers. )
    >>
    >> Running this test will at least enable you to know
    >> whether your system is configured to send email
    >> using CDOSYS, and whether your ISP's configuration
    >> allows mail to be sent through their smtp server.
    >>
    >> Then we could look for the reasons why
    >> it's not working from your ASP.NET app.
    >>
    >> Let us know how it goes.
    >>
    >>
    >>
    >> Juan T. Llibre
    >> ASP.NET MVP
    >> ===========
    >> "Andreas" <> wrote in message
    >> news:...
    >> > Thanks for the reply!
    >> >
    >> > I still have the same problem and I have found out that I have these
    >> > DLL's
    >> > installed:
    >> >
    >> > I have on the win2003 Web Server:
    >> > cdosys.dll
    >> > mapi32.dll
    >> >
    >> > I do NOT have on the win2003 Web Server
    >> > cdonts.dll
    >> > cdo.dll
    >> > cdoex.dll
    >> >
    >> > ---------------------------------------
    >> >
    >> > I have in my XP dev. computer:
    >> > cdo.dll
    >> > cdosys.dll
    >> > mapi32.dll
    >> >
    >> > I do NOT have in my XP dev. computer:
    >> > cdonts.dll
    >> > cdoex.dll
    >> >
    >> > I an trying to catch the expection but nothing is being thrown...
    >> >
    >> > / Andreas

    >>
    >>
    >>
     
    Juan T. Llibre, Jan 18, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rodrigo
    Replies:
    1
    Views:
    702
    Marina
    Aug 28, 2003
  2. Replies:
    12
    Views:
    698
    Grant Edwards
    Oct 16, 2006
  3. Gabriel Genellina

    Re: smtplib send email by using gmail smtp server

    Gabriel Genellina, May 3, 2009, in forum: Python
    Replies:
    0
    Views:
    452
    Gabriel Genellina
    May 3, 2009
  4. fniles
    Replies:
    22
    Views:
    4,648
    Michel Posseth [MCP]
    Apr 29, 2010
  5. ashish makani
    Replies:
    5
    Views:
    607
    Mark Lawrence
    Sep 20, 2012
Loading...

Share This Page