By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,981 Members | 1,098 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,981 IT Pros & Developers. It's quick & easy.

Open outlook message window

P: n/a
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?

Jan 24 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a

You have to add a reference to the Outlook Interop first, then doing
something like this should work:

Outlook.Application oApp = new Outlook.Application();
Outlook.MailItem oMsg =
(Outlook.MailItem)oApp.CreateItem(Outlook.OlItemTy pe.olMailItem);
Outlook.Recipient oRecip;

Then for every recipient you want to add:

oRecip = (Outlook.Recipient)oMsg.Recipients.Add("te**@test. com");
oRecip.Resolve();

Then use this call to display the message window:

oMsg.Display(true);

Finally, remember to set all objects to null once you are done:

oRecip = null;
oMsg = null;
oApp = null;

Hope this helps.

Sincerely,
Kevin Wienhold

On 24 Jan., 16:42, "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?
Jan 24 '07 #2

P: n/a


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);

Jan 24 '07 #3

P: n/a
Thanks to you both! I assume the steps are the same with VSTO.

Jan 24 '07 #4

P: n/a
On Jan 24, 1:26 pm, "Andy" <a...@med-associates.comwrote:
Thanks to you both! I assume the steps are the same with VSTO.
I haven't used VSTO, but the Microsoft presentations I've been to seem
to indicate that it is substantially different, and _much_ easier to
use.

You'll still have to add some sort of a reference to your project, but
the object hierarchy may be different.

Jan 25 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.