On Jan 24, 7:42 am, "Andy" <a...@med-associates.comwrote:
Hi,
I have a C# application and I'd like it to use Outlook 2003 to send
messages.
I don't want to send them programmaticlly though; I just want to open
the New Messge window, set the recipients and leave it there for the
user to finish filling out.
What classes am I looking for?
Well, first of all you need to add an Interop to your project for
Outlook. In the Solution Explorer, right-click on "References" under
your project and choose "Add Reference...". Go to the COM tab. Which
entry you need to add depends upon your version of Office.
For example, I have an interop for Office XP. Once I add a reference to
the COM component for Outlook XP, I can reference the namespace
Outlook. My code looks like this:
Outlook.Application outlookApp = new Outlook.Application();
Outlook.MailItem message =
(Outlook.MailItem)outlookApp.CreateItem(Outlook.Ol ItemType.olMailItem);
message.Subject = "Hello";
message.Recipients.Add("so*****@email.com");
message.Body = "Hello. Hope you're doing well.";
int attachmentLocation = 1;
message.Attachments.Add(fileName, Outlook.OlAttachmentType.olByValue,
attachmentLocation, displayName);
message.Display(false);