A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Creating New Email Programatically



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 27th 07, 11:36 PM posted to microsoft.public.outlook.program_addins
[email protected]
external usenet poster
 
Posts: 5
Default Creating New Email Programatically

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(Microsof t.Office.Interop.Outlook.OlDefaultFolders.olFolder Outbox);
Outlook.MailItem newMailItem =
(Outlook.MailItem)filter.outBoxfolder.Items.Add(Ou tlook.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.

  #2  
Old September 28th 07, 01:45 AM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Creating New Email Programatically

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

wrote in message
ups.com...
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(Microsof t.Office.Interop.Outlook.OlDefaultFolders.olFolder Outbox);
Outlook.MailItem newMailItem =
(Outlook.MailItem)filter.outBoxfolder.Items.Add(Ou tlook.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.



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Task from Email -- How can I Link Back to Original Email? Steve Newhouse Outlook and VBA 1 July 19th 07 04:36 PM
Inserting a buildingblock item into an email programatically Mikael Outlook and VBA 2 March 26th 07 03:44 PM
Creating Outlook Search Folder Programatically. Elanchezhian.R Outlook and VBA 2 February 7th 07 06:09 AM
creating new email eblaster Outlook - General Queries 1 August 9th 06 02:28 PM
Changing the FROM address when sending email programatically mecg96 Outlook and VBA 1 April 20th 06 09:42 PM


All times are GMT +1. The time now is 03:36 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.