How can I set the sent flag (and sendername etc) for a newly created
MailItem.
This is what I have so far but it doesn't work :-(
MAPIFolder oInbox =
mNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) ;
MailItem oItem =
(MailItem)mApplicationObject.CreateItemFromTemplate("C:\\Program
Files\\Microsoft Office\\Office\\VoiceRite.oft", oInbox);
oItem.Save();
string ID = oItem.EntryID;
oItem = (MailItem)mNameSpace.GetItemFromID(ID, oInbox.StoreID);
Redemption.SafeMailItem sItem =
(Redemption.SafeMailItem)mApplicationObject.CreateObject("Redemption.SafeMai
lItem");
sItem.Item = oItem;
int prMessageFlags = 0x0E070003;
int prSenderName = 0x0C1A001E;
int prSenderEmailAddress = 0x0C1F001E;
sItem.set_Fields(prSenderEmailAddress, "sender@here.com");
sItem.set_Fields(prMessageFlags, 0);
sItem.set_Fields(prSenderName, "Sender Name");
oItem.Save();
oItem.Move(oInbox);
oItem = null;
sItem = null;
oInbox = null;
Tim Attwood
Ken Slovak - [MVP - Outlook] - 24 Dec 2003 14:25 GMT
Sent is read-only. It's set by the spooler after you submit a message
to it.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginners Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> How can I set the sent flag (and sendername etc) for a newly created
> MailItem.
[quoted text clipped - 12 lines]
> oItem = (MailItem)mNameSpace.GetItemFromID(ID, oInbox.StoreID);
> Redemption.SafeMailItem sItem =
(Redemption.SafeMailItem)mApplicationObject.CreateObject("Redemption.S
afeMai
> lItem");
> sItem.Item = oItem;
[quoted text clipped - 15 lines]
>
> Tim Attwood
Dmitry Streblechenko - 28 Dec 2003 17:41 GMT
Sent flag is read-write before the first save and read-only after that. It
can be set by a spooler only.
If you are creating a message from the scratch, create it as an PostItem
rather than MailItem (it is created in a sent state), then reset the
MessageClass property back to IPM.Note. You cannot do this for an existing
MailItem.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> How can I set the sent flag (and sendername etc) for a newly created
> MailItem.
[quoted text clipped - 12 lines]
> oItem = (MailItem)mNameSpace.GetItemFromID(ID, oInbox.StoreID);
> Redemption.SafeMailItem sItem =
(Redemption.SafeMailItem)mApplicationObject.CreateObject("Redemption.SafeMai
> lItem");
> sItem.Item = oItem;
[quoted text clipped - 15 lines]
>
> Tim Attwood