Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / September 2007

Tip: Looking for answers? Try searching our database.

Creating New Email Programatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
78.sergey@gmail.com - 27 Sep 2007 23:36 GMT
Hi All

I am new to this Outlook development through VSTO and needed a quick
clarification.

I am creating new emails in my app (using VSTO & C#) programatically
and am able to do that but was not sure if this is the best way to do
it:

Here is what I do:

public Outlook.MAPIFolder outBoxfolder;
outBoxfolder =
app.GetNamespace("MAPI").GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox);
Outlook.MailItem newMailItem =
(Outlook.MailItem)filter.outBoxfolder.Items.Add(Outlook.OlItemType.olMailItem);
newMailItem.Subject = mycopiedItem.Subject + " (Please treat this as
Private)";
newMailItem.To = "aaa.hotmail.com";
newMailItem.CC = string.Empty;
newMailItem.BCC = string.Empty;

The above code works but Please let me know if there is a better way
to create new emails.
Dmitry Streblechenko - 28 Sep 2007 01:45 GMT
There is no better or worse way: it all depends on what you arae trying to
achieve.
Use MAPIFolder.Items.Add if you arae creating gan item in a particular
folder (keep in midnd that Outlook always creates mail items in teh Drafts
fodler - bug) or call Application.CreateItme() if you wnat the new item to
be created in the default folder for the specified item kind.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

> Hi All
>
[quoted text clipped - 20 lines]
> The above code works but Please let me know if there is a better way
> to create new emails.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.