Fake a .Sent

G

Guest

I need to Save an e-mail to a temp folder WITH the status of MailIte.Sent =
True. However, the e-mail has not been sent yet. Confused yet?

If I should open that MSG file, I need it's property to be .Sent = True.

Is it possible to fake a .Sent property? Is there a work-around to this odd
request?

Thanks,
DG
 
D

Dmitry Streblechenko

One possible workaround is to create a message a post item (PostItem) (it is
always created in the sent state), then change its MessageClass property
back to "IPM.Note". You would still need to delete (or change) the
PR_ICON_INDEX MAPI property to make sure the icon is right.
<plug> Redemption (url) below allows to set the RDOMail.Sent property before
the item is saved for the very first time (MAPI limitation)</plug>

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

Guest

Suppose the message was already written and I just want the user to select a
button to perform some action and then a Send. So after a successful send, I
run the following:

Dim myOlApp As New Outlook.Application
Dim myFolder As Outlook.MAPIFolder
Dim myEntryID As String
Dim myStoreID As String
Dim myNewFolder As Outlook.MailItem

myFolder =
myOlApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail)
myEntryID = EID --I retrieved this before I sent and after I saved it
myStoreID = myFolder.StoreID
myNewFolder = myOlApp.Session.GetItemFromID(myEntryID, myStoreID)
myNewFolder.Display()

So now my logic is to recapture the e-mail AFTER it's sent from the Sent
Folder so that I can save the MSG file appropriately. However, I'm getting an
error (a neg. Hex error) on the GetItemFromID. Any ideas?
 
D

Dmitry Streblechenko

What is the number? After the message is sent and moved to the Sent Items
folder, its entry id changes (unless you are using PST, but that's just a
peculiarity of the PST provider).

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

Guest

-1663827697
The Operation Failed

I first save the e-mail to Drafts folder and I capture the EntryID. If I
understand you correctly, the newly Sent e-mail will have a different EntryID
than the one I saved to Draft. Is this correct? Any better way? I don't mind
using your method of RDO but it's a little more complex due to an older
version of Redemption.dll (prior to RDO) installed on each PC from a
different application. So I am trying to avoid it.
 
D

Dmitry Streblechenko

Yes, the entry ids will change when the item is moved to the Outbox first,
then again when it is moved to the Sent Items folder.
You will be better off using the ItemAdd event on the Sent Items folder
contents table (Items collection).

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

Guest

Dmitry, if I understand your past messages I have read throughout all the
other message boards correctly, I need to use MAPIFolder.Items.ItemAdd as an
event to the "Sent" folder. So as an e-mail is dropped to the Sent folder,
ItemAdd is called which leads to my call. What I can't figure out is if it's
even possible to catch this event using VSTO / VB.Net? In all your examples
with Sue Mosher, it's only VBA. Your thoughts?

Thanks Dmitry, as always, I owe you!

DG
 
D

Dmitry Streblechenko

private Outlook.Items mSentItems; //make it a class variable to make sure it
does not get collected
....
{
mSentItems =
Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderSentMail).Items;
mSentItems.ItemAdd += ItemAddHandler;
}

void ItemAddHandler(object Item)
{
//
}

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

Jeff

To make sure that your event handler works correctly, I would hold
onto the Items reference for the lifetime of your application. I've
had problems w/ anonymous intermediary interop objects getting
disposed and then the event handler never being called.

Something like:

Items _sentItems;//a class field
....
this._sentItems =
Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderSentMail).Items;
....
this._sentItems.ItemAdd += ItemAddHandler;

jb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top