473,394 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 28413

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.