none
Send email using Outlook (Question 2)

    Question

  • Hi ,
    thank you for your advise, which looks promising. I'll describe to you the context of the problem in greater detail, if I may.
    On the webserver, I have disabled the SMTP service. I have been using MailEnable Standard Edition, a free email server. I do this basically because I dont understand how mail is send from Windows Server. It all works fine in our development environment here-emails are sent from the webserver to eg my Yahoo account, gmail account etc with no problems. However, in my client's site (a larger medical device company in Ireland), the emails appear to be sent (there is no crashing on sending), but they never arrive at their destination. Their SMTP server is in Belgium.

    Should I
    (1) remove MailEnable
    (2) install the SMTP service on the webserver
    (3) create a new domain (selecting the Remote option)
    (4) naming it the dns name of the mailserver
    (5) selecting Allow incoming mail to be relayed to this domain
    (6) select the forward all mail to smarthost option, specifying the ip address of the mail server in belgium?


    Regards!

    ==============================================================
    The issue is likely to be permissions related i.e. the user your asp.net application is running under (aspnet/networkuser) cannot access the COM components. This is correct behaviour (otherwise anonymous websites could access dangerous com components). If it's an internal setup, you could disable anonymous authentication, and run the asp.net application under a particular user (using impresonation), and then try it.

    I'd recommend that you don't do that as theres a number of issues
    1) outlook will popup a prompt you can't disable as it's setup to not allow automatic mail by default (to protect against spam).
    2) it's insecure (COM requires fulltrust code access security)

    Please try the mail classes as recommended. If you're not getting an error the mail is working, but the smtp forwarding is not. If you open the IIS MMC, you'll see a node for SMTP, to forward the mail to a mail server. If you've got a mail server such as Exchange, then this is often best to use the smarthost setting. Alternatively, this is a good reference to set this up. Once it's working correctly, the queued messages will automatically send.

    Cathal

    ====================================================================

    Hello,

    I want to send an email via Outlook 2003 (SP1) from an asp.net page. I have
    tried using the SMTP classes as recommended by Microsoft, but the environment
    of my client, the email messages never arrive when sent using  this method;
    hense using MS Otlook on the wenserver. The code is below:

       Dim oApp As Microsoft.Office.Interop.Outlook.Application
            oApp = New Microsoft.Office.Interop.Outlook.Application
            ' Create a new MailItem.
            Dim oMsg As Microsoft.Office.Interop.Outlook.MailItem
            oMsg =
    CType(oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem), Microsoft.Office.Interop.Outlook.MailItem)
            oMsg.Subject = "Hello!!!"
            oMsg.Body = "Hello World"
            oMsg.To = "me@gmail.com"
            oMsg.Send()

     

    The code runs fine in the Visual Studio 2005 development web server, but a
    security error is thrown on publishing to iis 6 (on windows server sp1):
    Retrieving the COM class factory for component with CLSID
    {0006F03A-0000-0000-C000-000000000046} failed with HRESULT: 0x80070005(Access
    is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))).
    Can anyone advise?

    Tuesday, September 20, 2005 4:20 PM

Answers

  • Hello cathie,

    using outlook from an ASP page is not a good way to send email from an server.
    1. the ASP Account must have an Outlook profile.
    2. Outlook needs a Desktop and sometimes it pops up messageboxes (reminders, etc.) - the ASP service runs without a Userinterface.
    3. Sending an email from outside Outlook hits the security Guard.

    I strongly recommend to send an Email with the integrated SMTP function from System.Web namespace.
    As I know the SMTP-Service must not be installed, you can use an external server like the Exchangeserver within the Customer network. 

    I recommend never install Outlook on a production server.

    Here is an example ( .Net 1.1 and .Net2.0 ) of a Codebehind page


     
     using System.Web;
     using System.Web.UI.WebControls;
     using System.Web.UI.HtmlControls;

     System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
     mail.From = "mustbe@acorrect.emailaddress"; 
     mail.To = "someone@internet.com;someother@internet.com";  
     mail.Subject = "Here goes the Subject";
     mail.Body = "Here comes the body...";
       
     System.Web.Mail.SmtpMail.SmtpServer = "smtp.server.of.customer";

     System.Web.Mail.SmtpMail.Send(mail);

     



    hope this helps,
    greets, Helmut Obertanner
    [http://www.x4u.de]

    Wednesday, September 21, 2005 6:45 AM

All replies

  • Hello cathie,

    using outlook from an ASP page is not a good way to send email from an server.
    1. the ASP Account must have an Outlook profile.
    2. Outlook needs a Desktop and sometimes it pops up messageboxes (reminders, etc.) - the ASP service runs without a Userinterface.
    3. Sending an email from outside Outlook hits the security Guard.

    I strongly recommend to send an Email with the integrated SMTP function from System.Web namespace.
    As I know the SMTP-Service must not be installed, you can use an external server like the Exchangeserver within the Customer network. 

    I recommend never install Outlook on a production server.

    Here is an example ( .Net 1.1 and .Net2.0 ) of a Codebehind page


     
     using System.Web;
     using System.Web.UI.WebControls;
     using System.Web.UI.HtmlControls;

     System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
     mail.From = "mustbe@acorrect.emailaddress"; 
     mail.To = "someone@internet.com;someother@internet.com";  
     mail.Subject = "Here goes the Subject";
     mail.Body = "Here comes the body...";
       
     System.Web.Mail.SmtpMail.SmtpServer = "smtp.server.of.customer";

     System.Web.Mail.SmtpMail.Send(mail);

     



    hope this helps,
    greets, Helmut Obertanner
    [http://www.x4u.de]

    Wednesday, September 21, 2005 6:45 AM
  • Thanks Helmut,
    I agree that is unwise to use Outlook on the webserver to send emails. I'm trying now to learn to use the the Virtual SMTP Server in IIS. Does anyone know offhand any good websites/advise on how to use the Default SMTP Virtual Server?
    Thursday, September 22, 2005 9:26 AM
  • Hello cathie,

    there is nothing fancy to know about.
    As long as your server can query DNS and can send through the firewall on port 25 it should work.

    cou can test it in the server with telnet:
    open a commandprompt on the server and type the following:

    telnet localhost 25
    you should see an answer of the SMTP Service.
    type HELO followed by an enter
    you should see 250 .... (250 is ok)

    type mail from:sender@email.address followed by an enter
    type rcpt to:receipient@email.address followed by an enter

    type data followed by an enter
    type the message
    type .  followed by an enter

    type quit

    so you can test if the webserver smtp service can deliver messages to outside.


    However, you should test that the smtp service couldn't be abused for relaying or spammers.

    But remember, as I know the smtp service must not be installed to use the code from above. You could also use an existing smtp server on another machine for that.

    hope this helps,
    regards, Helmut
    Thursday, September 22, 2005 12:26 PM
  • Hello Cathie, did you found the way to fix the following error?

    Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due.......

    I know that using Outlook is not a good idea but it's a client requirement

    cgodinez@technomex.net

    Thanks

    Saturday, October 28, 2006 5:28 PM
  • Even I'm getting this same error.

     

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

    System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005.

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

     

    I'm using .Net 2.0 to send Outlook Reminders.

    I've deployed this in server and it was working for the first couple of weeks.. I have Outlook also installed in the server.

     

    Can any one please help.

     

    Thanks in advance..

    Sunday, September 16, 2007 3:27 AM
  • Sujith, as Helmut noted earlier, automating Outlook from ASP.NET is not supported, nor is automation through a service. If by "sending reminders" you mean you are sending meeting requests, an appropriate solution would be to use iCalendar instead.

    Tuesday, September 18, 2007 4:17 PM
  • Thanks for the reply..!!

     

    It was not ASP,Net which I am using to send those calendar requests.

    But, It was a windows application (VB.Net 2.0), which will run as a scheduled task in the server.

     

    Any way, the mentioned error got rectified.

    It was a problem with MS Outlook Installation.

    I was having MS Outlook 2007 in the server at the time of deployment of my application. Later some one else installed Office 2003 there. They forget to skip Outlook 2003. So there were two instances of MS Outlook (2003 & 2007). Infact both were not working..

     

    I uninstalled  both and installed MS Outlook 2007 it again.

    And, It started working again.

     

    Thanks Again !!!
    Saturday, September 22, 2007 4:06 AM
  • Sujith, I'm glad to hear you solved your problem, but note please that automating Outlook from a scheduled task is also not supported.

    Saturday, September 22, 2007 7:19 PM
  • So what, I ask, is the way to do this?

    I have a similar problem (trying to book a resource on a shared calendar from a desktop Access application) and saying iCalendar by itself with no links is not useful.  The search I did of msdn using iCalendar turned up this thread which as it is, is useless to me.

     

    Wednesday, December 05, 2007 9:10 PM
  • mstewart14, the solution given for a server scenario wouldn't necessarily apply to a desktop Access application. I'd suggest that you start a new topic thread on your particular issue, with as much detail as you can muster. This is the right forum if you are building a VSTO add-in for Access or Outlook. If not, then the appropriate place to post would be in the newsgroup at http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.outlook.program_vba

    Wednesday, December 05, 2007 9:17 PM