Will

Will

  • NA
  • 1
  • 0

Sorry - Real Beginner question - Re: Outlook C#

Jul 31 2008 6:28 AM

All I want to do is show the user the email that has been created and allow them to modify / choose when to send.

Thanks very much in advance.

Will.

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Runtime.InteropServices;

using Outlook = Microsoft.Office.Interop.Outlook;

using System.Windows.Forms;

/// This Code is adopted from Microsoft Knowlegdebase Article:  <http://support.microsoft.com/?kbid=220600>

 

           

// The Outlook Application Object

Outlook.ApplicationClass myOutlookApplication = null;

 

// Create the Application Object

myOutlookApplication = new Outlook.ApplicationClass ();

 

// Get the Namespace Object

Outlook.NameSpace myNameSpace = myOutlookApplication.GetNamespace("MAPI");

 

// Define a missing Object for COM interop

object myMissing = System.Reflection.Missing.Value ; 

 

// Logon to Namespace

myNameSpace.Logon(myMissing, myMissing, myMissing, myMissing);

 

// Create a Mail Object

 

 

Outlook._MailItem myNewMail = (Outlook._MailItem)myOutlookApplication.CreateItem(Outlook.OlItemType.olMailItem);

 

 

//Outlook.MailItemClass myNewMail = (Outlook.MailItemClass) myOutlookApplication.CreateItem (Outlook.OlItemType.olMailItem);

 

myNewMail.To = "[email protected]";

myNewMail.Subject = "About our meeting...";

myNewMail.Body = "Hi James,\n\n" +

                        "\tI'll see you in two minutes for our meeting!\n\n" +

                        "Btw: I've added you to my contact list!";

 

// Send the message!

myNewMail.Send();

 

//* CleanUp

Marshal.ReleaseComObject (myNewMail);

 

myNameSpace.Logoff ();

Marshal.ReleaseComObject (myNameSpace);

Marshal.ReleaseComObject (myOutlookApplication);


Answers (1)