1
Answer

Sorry - Real Beginner question - Re: Outlook C#

Photo of Will

Will

16y
3.1k
1

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 = "test@test.co.uk";

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)

0
Photo of Sam Hobbs
NA 28.7k 1.3m 15y
You must use the documentation of the software. Unless the preson helping is psychic, no one here can tell you how to use the software without the information that is in the documentation. If this is an urgent matter, then the fastest way to solve the problem is for you to read the documentation.
Accepted
0
Photo of Rujuta
NA 1.7k 53.1k 15y
You will also need to get hold of the software's API or DLL files.

This way you can integrate it with your application.
0
Photo of ila
NA 5.6k 0 15y
Ok Sam.. Thank You