Send Email from C# via Outlook 
Author Message
 Send Email from C# via Outlook

Hello,

Am having a problem as outlook does not recognize this.
Have included the two classes. Thanks in advance:

sending email...Have two Classes as follows:

                        OutlookMail MyOutlookmail = new
OutlookMail();
                        MyOutlookmail.addToOutBox
(myDataView[i]["EmailAddress"].ToString(),myDataView[i]
["LastName"].ToString(),myDataView[i]
["Firstname"].ToString());
                        ///MyOutlookmail.addToOutBox
(myDataView[i]["EmailAddress"].ToString(),Subject.ToString
(),MsgBody.ToString());            

called class....

using System;

namespace RealtorEmail
{
        /// <summary>
        /// Summary description for OutlookMail.
        /// </summary>
        public class OutlookMail
        {
                private Outlook._Application oApp;
                private Outlook._NameSpace oNameSpace;
                private Outlook.MAPIFolder oOutboxFolder;
                public OutlookMail()
                {
                        //
                        // Return a reference to the MAPI
layer
                        //
                        oApp = new Outlook.Application();

                        oNameSpace = oApp.GetNamespace
("MAPI");
                        oNameSpace.Logon
(null,null,true,true);
                        // gets default folder for my
outlook Outbox
                        oOutboxFolder =
oNameSpace.GetDefaultFolder

        (Outlook.OlDefaultFolders.olFolderOutbox);
                }
                public void addToOutBox(string toValue,
string subjectValue, string bodyValue)
                {
                        Outlook._MailItem oMailItem =
(Outlook._MailItem)oApp.CreateItem

        (Outlook.OlItemType.olMailItem);
                        oMailItem.To = toValue;
                        oMailItem.Subject = subjectValue;
                        oMailItem.Body = bodyValue;
                        oMailItem.SaveSentMessageFolder =
oOutboxFolder;
                        oMailItem.Send();      
                }
        }

Quote:
}



Tue, 22 Mar 2005 09:57:48 GMT  
 Send Email from C# via Outlook
Use SMTPMail class. It is simpler than this.


Quote:
> Hello,

> Am having a problem as outlook does not recognize this.
> Have included the two classes. Thanks in advance:

> sending email...Have two Classes as follows:

>   OutlookMail MyOutlookmail = new
> OutlookMail();
>   MyOutlookmail.addToOutBox
> (myDataView[i]["EmailAddress"].ToString(),myDataView[i]
> ["LastName"].ToString(),myDataView[i]
> ["Firstname"].ToString());
> ///MyOutlookmail.addToOutBox
> (myDataView[i]["EmailAddress"].ToString(),Subject.ToString
> (),MsgBody.ToString());

> called class....

> using System;

> namespace RealtorEmail
> {
> /// <summary>
> /// Summary description for OutlookMail.
> /// </summary>
> public class OutlookMail
> {
> private Outlook._Application oApp;
> private Outlook._NameSpace oNameSpace;
> private Outlook.MAPIFolder oOutboxFolder;
> public OutlookMail()
> {
> //
> // Return a reference to the MAPI
> layer
> //
> oApp = new Outlook.Application();

> oNameSpace = oApp.GetNamespace
> ("MAPI");
> oNameSpace.Logon
> (null,null,true,true);
> // gets default folder for my
> outlook Outbox
> oOutboxFolder =
> oNameSpace.GetDefaultFolder

> (Outlook.OlDefaultFolders.olFolderOutbox);
> }
> public void addToOutBox(string toValue,
> string subjectValue, string bodyValue)
> {
> Outlook._MailItem oMailItem =
> (Outlook._MailItem)oApp.CreateItem

> (Outlook.OlItemType.olMailItem);
> oMailItem.To = toValue;
> oMailItem.Subject = subjectValue;
> oMailItem.Body = bodyValue;
> oMailItem.SaveSentMessageFolder =
> oOutboxFolder;
> oMailItem.Send();
> }
> }
> }



Tue, 22 Mar 2005 14:26:07 GMT  
 Send Email from C# via Outlook
No it's not possible to use SMTPMail to access a MAPI store.
The guy is talking about Outlook using the MAPI protocol, not OE which uses SMTP.

Willy.

Quote:

> Use SMTPMail class. It is simpler than this.



> > Hello,

> > Am having a problem as outlook does not recognize this.
> > Have included the two classes. Thanks in advance:

> > sending email...Have two Classes as follows:

> >   OutlookMail MyOutlookmail = new
> > OutlookMail();
> >   MyOutlookmail.addToOutBox
> > (myDataView[i]["EmailAddress"].ToString(),myDataView[i]
> > ["LastName"].ToString(),myDataView[i]
> > ["Firstname"].ToString());
> > ///MyOutlookmail.addToOutBox
> > (myDataView[i]["EmailAddress"].ToString(),Subject.ToString
> > (),MsgBody.ToString());

> > called class....

> > using System;

> > namespace RealtorEmail
> > {
> > /// <summary>
> > /// Summary description for OutlookMail.
> > /// </summary>
> > public class OutlookMail
> > {
> > private Outlook._Application oApp;
> > private Outlook._NameSpace oNameSpace;
> > private Outlook.MAPIFolder oOutboxFolder;
> > public OutlookMail()
> > {
> > //
> > // Return a reference to the MAPI
> > layer
> > //
> > oApp = new Outlook.Application();

> > oNameSpace = oApp.GetNamespace
> > ("MAPI");
> > oNameSpace.Logon
> > (null,null,true,true);
> > // gets default folder for my
> > outlook Outbox
> > oOutboxFolder =
> > oNameSpace.GetDefaultFolder

> > (Outlook.OlDefaultFolders.olFolderOutbox);
> > }
> > public void addToOutBox(string toValue,
> > string subjectValue, string bodyValue)
> > {
> > Outlook._MailItem oMailItem =
> > (Outlook._MailItem)oApp.CreateItem

> > (Outlook.OlItemType.olMailItem);
> > oMailItem.To = toValue;
> > oMailItem.Subject = subjectValue;
> > oMailItem.Body = bodyValue;
> > oMailItem.SaveSentMessageFolder =
> > oOutboxFolder;
> > oMailItem.Send();
> > }
> > }
> > }



Wed, 23 Mar 2005 05:15:51 GMT  
 Send Email from C# via Outlook
What exactly do you mean by "does not recognize " ?
Any error messages at runtime or do you have compile time errors?

Willy.

Quote:

> Hello,

> Am having a problem as outlook does not recognize this.
> Have included the two classes. Thanks in advance:

> sending email...Have two Classes as follows:

>   OutlookMail MyOutlookmail = new
> OutlookMail();
>   MyOutlookmail.addToOutBox
> (myDataView[i]["EmailAddress"].ToString(),myDataView[i]
> ["LastName"].ToString(),myDataView[i]
> ["Firstname"].ToString());
> ///MyOutlookmail.addToOutBox
> (myDataView[i]["EmailAddress"].ToString(),Subject.ToString
> (),MsgBody.ToString());

> called class....

> using System;

> namespace RealtorEmail
> {
> /// <summary>
> /// Summary description for OutlookMail.
> /// </summary>
> public class OutlookMail
> {
> private Outlook._Application oApp;
> private Outlook._NameSpace oNameSpace;
> private Outlook.MAPIFolder oOutboxFolder;
> public OutlookMail()
> {
> //
> // Return a reference to the MAPI
> layer
> //
> oApp = new Outlook.Application();

> oNameSpace = oApp.GetNamespace
> ("MAPI");
> oNameSpace.Logon
> (null,null,true,true);
> // gets default folder for my
> outlook Outbox
> oOutboxFolder =
> oNameSpace.GetDefaultFolder

> (Outlook.OlDefaultFolders.olFolderOutbox);
> }
> public void addToOutBox(string toValue,
> string subjectValue, string bodyValue)
> {
> Outlook._MailItem oMailItem =
> (Outlook._MailItem)oApp.CreateItem

> (Outlook.OlItemType.olMailItem);
> oMailItem.To = toValue;
> oMailItem.Subject = subjectValue;
> oMailItem.Body = bodyValue;
> oMailItem.SaveSentMessageFolder =
> oOutboxFolder;
> oMailItem.Send();
> }
> }
> }



Wed, 23 Mar 2005 05:17:35 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to send bitmap to email (outlook express)

2. Sending email through Outlook

3. how to send an Email via SMTP (with attached file)

4. How to send and get email via SMTP ?

5. sending a file via email

6. help sending html via email with mfc?

7. Send attachments via email

8. C#: Sending Lotus Notes email messages

9. Sending a multipart/alternative email in C#

10. Sending Email Help (C#)

11. how read/write email in C# via Outlook express ?

12. Accessing Outlook Email and Folder Stuff

 

 
Powered by phpBB® Forum Software