Setting "sent" flag

  • Thread starter Thread starter Tim Attwood
  • Start date Start date
T

Tim Attwood

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, "(e-mail address removed)");
sItem.set_Fields(prMessageFlags, 0);
sItem.set_Fields(prSenderName, "Sender Name");

oItem.Save();
oItem.Move(oInbox);

oItem = null;
sItem = null;
oInbox = null;

Tim Attwood
 
Sent is read-only. It's set by the spooler after you submit a message
to it.
 
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
 
Back
Top