472,984 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,984 software developers and data experts.

Open outlook message window

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
4 28357

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


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
Thanks to you both! I assume the steps are the same with VSTO.

Jan 24 '07 #4
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: MaxH | last post by:
I need to perform programmatically from a C# .net application the following tasks: _ open an outlook (or default e-mail client) compose message window; _ attach a document to the new message; _...
4
by: PerryC | last post by:
All, How to ensure SendObject open Outlook and Not Outlook Express? Most pc here at work will default to open OL but on one pc, it open up OL Express. How to fix this in the code? P.S.: I...
2
by: Patrick.O.Ige | last post by:
If i send an email using outlook and in the email there is a hyperlink. But what i want is that if people get the email and they click the link i want the new window to open with no address bar....
14
by: C | last post by:
Hi, From my ASP.NET application when the user clicksa button I want to be able to programmatically open Outlook, create a new mail, add attachments and set the body text. Is this possible? ...
5
by: raymonj | last post by:
Hi, Is it possible to display the Outlook recipient window from Vb.Net and receive the email selection the user has chosen when the window is closed ? Thanks folks.
0
by: bvasav | last post by:
Hi, Normally, when you use the outlook api to display an email message, it pops open a new window. Does anyone know of a way to instead display the Outlook window within a Custom Windows...
23
by: andyoye | last post by:
How can I launch Outlook on users machines when they click a button on a web form (InfoPath)? Thanks
0
by: Garth Nugent | last post by:
I've created a very simple Office Outlook addin (using Visual Studio 2010 C#) that displays a Winform pops up a window when a new message arrives (using NewMailEx), and adds the sender, subject and...
1
by: Dean Kemp | last post by:
Hi I have designed a button that sends a mail “automated” by the system. But it doesn’t work if outlook is closed. And I have a string of code that opens outlook but then it opens on top of my app....
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.