outlook vba - Create a mail object and track it down in sent folder -



outlook vba - Create a mail object and track it down in sent folder -

i need create mail service via vba, send it, , export .msg file of sent mail service archived (i know, it's weird, that's boss asked for).

creating mail service straightforward:

set olk = outlook.session set ml = olk.createitem olmailitem ml .recipients.add "somebody@somedomain.com" .subject = "great mail service have there" .body = "it shame if couldn't archive it" end ml.send

problem is, after sending mail service moved in sent folder , ml object points nothing.

i utilize .saveas method before sending, saved file unsent version, can edited , sent again.

how can trace mail service in sent folder?

the "brute force" way found out implies saving conversationindex before sending

idx= ml.conversationindex

and scan items in sent folder it:

for each ml in olk.session.getdefaultfolder(olfoldersentmail).items if ml.conversationindex = idx ml.saveas homedir & "\" & outfilename: exit next

but isn't smooth work.... (and may fail if smartass replies automatic mail, if nobody should)

you can add together user property (mailitem.userproperties.add), cause message sent in tnef format unless usetnef property (dasl name http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-c000-000000000046}/8582000b) explicitly set false.

you can set named mapi property using propertyaccessor.setproperty - pick custom guid , property name. e.g.

ml.propertyaccessor.setproperty("http://schemas.microsoft.com/mapi/string/{3ade3813-37a9-49c9-ad84-d49c8ff5d660}/myownprop", "somevalue")

outlook-vba

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -