PC Review


Reply
Thread Tools Rate Thread

How to save encrypted mail to disk (MSG) unencrypted

 
 
Damian Dekoszczak
Guest
Posts: n/a
 
      29th Dec 2011
Hi

as in topic, i'm looking for a programmatic way to save encrypted
email from inbox as unencrypted MSG file on disk. I want to do it from
outlook add-in. Outlook Spy does it, so somehow it is possible. Of
course saving by means on MailItem::SaveAs saves encrypted mail and so
does code below:


void SaveToMSG ( MailItem _item)

{

stringfilePath ="C:\\Users\\user\\Desktop\\"+ _item.Subject + ".msg";

IntPtriSecMsg =IntPtr.Zero;

IntPtriMsg;

IntPtriProp;

IntPtrptrGuid;

variUnknown =ptrGuid =iMsg = iProp = IntPtr.Zero;

IMapiPropprop = null;



iUnknown= Marshal.GetIUnknownForObject(_item.MAPIOBJECT);

var secMsg= (IMAPISecureMessage)_item.MAPIOBJECT;

secMsg.GetBaseMessage(refiMsg);

Marshal.QueryInterface(iMsg, ref _propGuid, out iProp);

prop=
(IMapiProp)Marshal.GetTypedObjectForIUnknown(iProp,typeof(IMapiProp));



IStoragepStorage =null;

IntPtrpMsgSession = IntPtr.Zero;

IMessagepIMsg = null;

varpMalloc =MAPIGetDefaultMalloc();



StgCreateDocfile(filePath,

STGM.READWRITE |

STGM.TRANSACTED |

STGM.CREATE, 0, out pStorage);



OpenIMsgSession(pMalloc, 0, out pMsgSession);



OpenIMsgOnIStg(pMsgSession,

Marshal.GetFunctionPointerForDelegate(new
MAPIAllocateBufferDelegate(MAPIAllocateBuffer)),

Marshal.GetFunctionPointerForDelegate(new
MAPIAllocateMoreDelegate(MAPIAllocateMore)),

Marshal.GetFunctionPointerForDelegate(new
MAPIFreeBufferDelegate(MAPIFreeBuffer)),

pMalloc,

IntPtr.Zero,

pStorage,

IntPtr.Zero, 0, 0x80000000, outpIMsg);



r= WriteClassStg(pStorage, new Guid("{00020D0B-0000-0000-
C000-000000000046}") );



var guid = new Guid("00020307-0000-0000-C000-000000000046");

r = prop.CopyTo(0, null,IntPtr.Zero,IntPtr.Zero, IntPtr.Zero,guid,
pIMsg, 0,IntPtr.Zero);

pIMsg.SaveChanges ( 2 );

pStorage.Commit(0);



Marshal.FinalReleaseComObject(pIMsg);

Marshal.FinalReleaseComObject(pStorage);

Marshal.ReleaseComObject(prop);

CloseIMsgSession( pMsgSession );

}



Any hints how to do it? i tried passing IMAPISecureMessage IID as a
second parameter of IMAPIProp::CopyTo (rgiidExclude) but to no avail.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
encrypted request from unencrypted page mtanner Microsoft ASP .NET 2 10th Nov 2005 08:40 PM
Unencrypted encrypted files on crashed hD? Bernie Windows XP Help 0 16th Jun 2005 08:46 PM
How to make an encrypted folder unencrypted rajendran@yahoo.com Microsoft Outlook 1 1st Feb 2005 09:49 AM
Unencrypted Password =?Utf-8?B?S2F0aHlG?= Windows XP Help 1 30th Sep 2004 02:18 PM
Re: How to Send Unencrypted Passwords to Connect Windows Jeffrey Randow (MVP) Windows XP Work Remotely 0 2nd Jul 2003 02:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:55 PM.