hello,
i'm working on c# 2005, and i want to open m.outlook(2003) without sending the email, but open an email message.
how can i do that?
thanks,
lala
5 2228
I had to do a lot of digging for this one when I needed it, so here's a little class: -
static class OutlookEmail
-
{
-
private static Microsoft.Office.Interop.Outlook.Application oApp= new Microsoft.Office.Interop.Outlook.Application();
-
private static Microsoft.Office.Interop.Outlook._NameSpace oNameSpace;
-
private static Microsoft.Office.Interop.Outlook.MAPIFolder oOutboxFolder;
-
-
public static void CreateEmail(string[] toValues, string subjectValue, string bodyValue)
-
{
-
//oApp = new Microsoft.Office.Interop.Outlook.Application();
-
oNameSpace = oApp.GetNamespace("MAPI");
-
oNameSpace.Logon(null, null, true, true);
-
oOutboxFolder = oNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox);
-
-
Microsoft.Office.Interop.Outlook._MailItem oMailItem = (Microsoft.Office.Interop.Outlook._MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
-
-
string theTO = "";
-
foreach(string toVal in toValues)
-
{
-
//oMailItem.Recipients.Add(toVal);
-
theTO += toVal + "; ";
-
}
-
oMailItem.To = theTO;
-
oMailItem.Subject = subjectValue;
-
oMailItem.Body = bodyValue;
-
//oMailItem.SaveSentMessageFolder = oOutboxFolder;
-
oMailItem.Display(null);
-
}
-
}
-
Be sure to also include a reference to:
Microsoft Outlook 11.0 Object Library
it works :)
thanks you!!!!!
I had to do a lot of digging for this one when I needed it, so here's a little class: -
static class OutlookEmail
-
{
-
private static Microsoft.Office.Interop.Outlook.Application oApp= new Microsoft.Office.Interop.Outlook.Application();
-
private static Microsoft.Office.Interop.Outlook._NameSpace oNameSpace;
-
private static Microsoft.Office.Interop.Outlook.MAPIFolder oOutboxFolder;
-
-
public static void CreateEmail(string[] toValues, string subjectValue, string bodyValue)
-
{
-
//oApp = new Microsoft.Office.Interop.Outlook.Application();
-
oNameSpace = oApp.GetNamespace("MAPI");
-
oNameSpace.Logon(null, null, true, true);
-
oOutboxFolder = oNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox);
-
-
Microsoft.Office.Interop.Outlook._MailItem oMailItem = (Microsoft.Office.Interop.Outlook._MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
-
-
string theTO = "";
-
foreach(string toVal in toValues)
-
{
-
//oMailItem.Recipients.Add(toVal);
-
theTO += toVal + "; ";
-
}
-
oMailItem.To = theTO;
-
oMailItem.Subject = subjectValue;
-
oMailItem.Body = bodyValue;
-
//oMailItem.SaveSentMessageFolder = oOutboxFolder;
-
oMailItem.Display(null);
-
}
-
}
-
Be sure to also include a reference to:
Microsoft Outlook 11.0 Object Library
That's neat, but if you don't mind me asking, why not just use mailto:whatever@someplace.ca,someotherguy@otherpla ce.com?subbject=blah&body=BlahAsWell
If you run the above (well double check the mailto syntax, but you get the idea) as a process with UseShellExecute = true, it will open whatever your default mail program is in the same manner, regardless of if they have outlook installed.
Your example does force it to be outlook though, which could be useful, and I'm sure gives you much greater control overall.
Have fun,
-mwalts
you can also refer the below article for more understanding outlook
Prabu
That's neat, but if you don't mind me asking, why not just use mailto:whatever@someplace.ca,someotherguy@otherpla ce.com?subbject=blah&body=BlahAsWell
If you run the above (well double check the mailto syntax, but you get the idea) as a process with UseShellExecute = true, it will open whatever your default mail program is in the same manner, regardless of if they have outlook installed.
Your example does force it to be outlook though, which could be useful, and I'm sure gives you much greater control overall.
Have fun,
-mwalts
That's neat, but if you don't mind me asking, why not just use mailto:whatever@someplace.ca,someotherguy@otherpla ce.com?subbject=blah&body=BlahAsWell
If you run the above (well double check the mailto syntax, but you get the idea) as a process with UseShellExecute = true, it will open whatever your default mail program is in the same manner, regardless of if they have outlook installed.
Your example does force it to be outlook though, which could be useful, and I'm sure gives you much greater control overall.
Have fun,
-mwalts
Well the request was for the ability to open outlook, not the default mailer.
As for Prabu, I believe I used some article I found here back when I created mine, but had to hack it apart to get it to work better. (I don't like having the "an application is trying to use outlook" popup coming up every 5secs as the article I read produced) I haven't gone through yours, but emailing help is always usefull. (I'm creating my own custom smtp class STILL)
Sign in to post your reply or Sign up for a free account.
Similar topics
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;
_...
|
by: Jordan |
last post by:
I created and access application that sends e-mails automaticaly to our
clients, over 1.500 e-mails daily.
I am using the MS Outlook components to create the e-mail with HTML code.
All works...
|
by: lauren quantrell |
last post by:
Is there a way to open the MS Outlook address book using VBA and then
be able to do something with the return value?
I want users to click an icon to open the Outlook address book then
when an...
|
by: Moti |
last post by:
I want to open, NOT to send, new email message.
I use:
Outlook.Application oApp = new Outlook.Application();
Outlook._NameSpac oNameSpace= oApp.GetNamespace("MAPI");...
|
by: Barkster |
last post by:
I'm trying to send using outlook but I get an error on the directcast line
if I don't have outlook open. Works fine if it is open. What do I need to
do to be able to send without having outlook...
|
by: bobdydd |
last post by:
Hi Everybody
Access 2000, Outlook 2000 Windows XP
I am running the code below to open Microsoft Outlook from a Command
Button. It works fine until I tried it on a machine that has Office...
|
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?
...
|
by: Andy |
last post by:
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...
|
by: keri |
last post by:
Hi,
I use the below for the user to view their outlook calendar
Sub DisplayInbox()
Dim myolApp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder...
|
by: andyoye |
last post by:
How can I launch Outlook on users machines when they click a button on a web
form (InfoPath)?
Thanks
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |