Send Email with MAPI

Discussion in 'ASP .Net' started by madfisher, Jan 12, 2006.

  1. madfisher

    madfisher Guest

    Hi,

    I am trying to send an email with MAP via C# and ASP.NET. This is what
    I'm doing.

    MapiSession1 = new MSMAPI.MAPISessionClass();
    MapiSession1.UserName = "OutlookProfileName";
    MapiSession1.Password = "pass";
    MapiSession1.LogonUI = false;
    MapiSession1.SignOn();
    MapiSession1.NewSession = true;

    MapiMessages1 = new MSMAPI.MAPIMessagesClass();
    MapiMessages1.SessionID = MapiSession1.SessionID;
    MapiMessages1.Compose();
    MapiMessages1.RecipAddress = "";

    MapiMessages1.MsgSubject = "New Build Requested";
    MapiMessages1.MsgNoteText = "A new build has been requested.";
    MapiMessages1.Send(null);

    MapiSession1.SignOff();

    I'm getting the following error:
    System.Runtime.InteropServices.COMException: Login has failed

    I'm am using my Outlook (Exchange profile info) which should be right.
    Am I going about this the right way?

    Thanks in advance.

    Marcus de Leon
     
    madfisher, Jan 12, 2006
    #1
    1. Advertising

  2. Marcus,
    If your Exchange server offers SMTP you should find that a lot easier using
    either System.Web.Mail (System.Net.Mail for ASP.NET 2.0) or any of a number
    of free, open source SMTP Libraries such as OpenSMTP.
    I hate MAPI.
    Peter

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "madfisher" wrote:

    > Hi,
    >
    > I am trying to send an email with MAP via C# and ASP.NET. This is what
    > I'm doing.
    >
    > MapiSession1 = new MSMAPI.MAPISessionClass();
    > MapiSession1.UserName = "OutlookProfileName";
    > MapiSession1.Password = "pass";
    > MapiSession1.LogonUI = false;
    > MapiSession1.SignOn();
    > MapiSession1.NewSession = true;
    >
    > MapiMessages1 = new MSMAPI.MAPIMessagesClass();
    > MapiMessages1.SessionID = MapiSession1.SessionID;
    > MapiMessages1.Compose();
    > MapiMessages1.RecipAddress = "";
    >
    > MapiMessages1.MsgSubject = "New Build Requested";
    > MapiMessages1.MsgNoteText = "A new build has been requested.";
    > MapiMessages1.Send(null);
    >
    > MapiSession1.SignOff();
    >
    > I'm getting the following error:
    > System.Runtime.InteropServices.COMException: Login has failed
    >
    > I'm am using my Outlook (Exchange profile info) which should be right.
    > Am I going about this the right way?
    >
    > Thanks in advance.
    >
    > Marcus de Leon
    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Jan 12, 2006
    #2
    1. Advertising

  3. madfisher

    madfisher Guest

    Yeah I know what you mean, SMTP would be much better, however the ports
    are blocked here at work and smtp isn't an option for me. Messages go
    in the Queue and don't get sent b/c it is unable to contact the server.
     
    madfisher, Jan 12, 2006
    #3
    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. Peter
    Replies:
    0
    Views:
    3,412
    Peter
    Jul 1, 2003
  2. Replies:
    2
    Views:
    435
    Tintin
    Jan 5, 2007
  3. Replies:
    0
    Views:
    193
  4. Replies:
    13
    Views:
    530
    Randy Webb
    May 14, 2006
  5. pbd22
    Replies:
    1
    Views:
    175
Loading...

Share This Page