set Session = CreateObject("Redemption.RDOSession")
set Msg = Session.GetMessageFromMsgFile("c:\newmsgFile.msg", true)
Msg.Import("c:\YourEmlFile.EML", 1024)
Msg.Save
</plug>
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Esther" <Est...@discussions.microsoft.com> wrote in message
news:ACC8047D-4CBB-48D3...@microsoft.com...
>I am in a crunch to convert internet mail .eml files to mapi .msg files in
> .net, using c#. I read about iConverterSession in the outlook 2003 api,
> but
> I can't seem to find enough information or any sample code on how to
> proceed.
> Can anyone point me in the right direction in regards to whether I have to
> add any reference in my code, etc. Some sample code would be very
> helpful.
>
> If this is not the best way to go, what's my alternative?
>
> Thanks.
> --
> edw
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Esther" <Est...@discussions.microsoft.com> wrote in message
news:8A8E88B0-1F19-4EE6...@microsoft.com...
> Dimitry, Thanks for your response. Is Extended MAPI not supported in
> .net?
> Could it be used with vb.net instead of c#? We have used redemption in
> another project that is similar to this, but they are looking to not use
> it
> here. Is there another way to approach this? Thanks.
> --
> edw
I'm learning how to use the Redemption dll...
My objective is to convert eml to msg, before to go in pure VB, I'm doing
some basic test in VBA (under excel),
I installed the CDO library, and declared this library in my vba environment
(Redemption Outlook Library)
I'm trying to reuse the code sample to are proposing such as:
Private Sub CB_ConvertEML2MSG_Click()
'1. Reference: Microsoft Outlook 11.0 Object Library
'2. Reference: Redemption Outlook Library
Set Session = CreateObject("Redemption.RDOSession")
EMLname = "EML_Origin_1"
MSGname = EMLname
EMLpath = ThisWorkbook.Path & EMLname & ".eml"
MSGpath = ThisWorkbook.Path & MSGname & ".msg"
Set Msg = Session.GetMessageFromMsgFile(MSGpath, True)
a = Msg.Import(EMLpath, 1024)
Msg.Save
End Sub
UNFORTUNATELY when a try to set the Session, the system prompts and tells me
that this object is only readable !!??
I guess it's a basic issue...however I failed finding the root-cause
Could you please help me?
Thanks a lot in advance,
Daniel.
I found the problem,
thanks
There are a large number of posts from developers interested in using
Microsoft Outlook's IConverterSession interface. I happen to be one of
those developers. As far I as see there are no type libraries or C++
headers provided. Any chance someone would be kind enough to post the C
++ header for the IConverterSession interface. There is one floating
around on the Internet but it only supports three functions.
Your help is much appreciated
Jamie
class NativeMethods
{
public enum CLSCTX
{
CLSCTX_INPROC_SERVER = 0x1,
CLSCTX_INPROC_HANDLER = 0x2,
CLSCTX_LOCAL_SERVER = 0x4,
CLSCTX_REMOTE_SERVER = 0x10,
CLSCTX_INPROC = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
CLSCTX_SERVER = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER,
CLSCTX_ALL = CLSCTX_SERVER | CLSCTX_INPROC_HANDLER
}
public static Guid CLSID_IConverterSession = new Guid("{4e3a7680-b77a-11d0-9da5-00c04fd65685}");
public static Guid IID_IConverterSession = new Guid("{4b401570-b77b-11d0-9da5-00c04fd65685}");
public enum ENCODINGTYPE
{
IET_BINARY = 0,
IET_BASE64 = 1,
IET_UUENCODE = 2,
IET_QP = 3,
IET_7BIT = 4,
IET_8BIT = 5,
IET_INETCSET = 6,
IET_UNICODE = 7,
IET_RFC1522 = 8,
IET_ENCODED = 9,
IET_CURRENT = 10,
IET_UNKNOWN = 11,
IET_BINHEX40 = 12,
IET_LAST = 13
}
public enum MIMESAVETYPE
{
SAVE_RFC822 = 0,
SAVE_RFC1521 = 1
}
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("4b401570-b77b-11d0-9da5-00c04fd65685")]
public interface IConverterSession
{
[PreserveSig]
int Placeholder0();
[PreserveSig]
int SetEncoding(
[In, MarshalAs(UnmanagedType.I4)] ENCODINGTYPE DispId
);
[PreserveSig]
int Placeholder1();
[PreserveSig]
int MIMEToMAPI(
[In, MarshalAs(UnmanagedType.Interface)]
Stream pstm,
[Out, MarshalAs(UnmanagedType.Interface)]
MailItem pmsg,
object pszSrcSrv,
uint ulFlags
);
[PreserveSig]
int MAPIToMIMEStm(
[In, MarshalAs(UnmanagedType.Interface)]
MailItem pmsg,
[Out, MarshalAs(UnmanagedType.Interface)]
Stream pstm,
uint ulFlags
);
[PreserveSig]
int Placeholder2();
[PreserveSig]
int Placeholder3();
[PreserveSig]
int Placeholder4();
[PreserveSig]
int SetTextWrapping(
bool fWrapText,
uint ulWrapWidth
);
[PreserveSig]
int SetSaveFormat(
[In, MarshalAs(UnmanagedType.I4)]
MIMESAVETYPE mstSaveFormat
);
[PreserveSig]
int Placeholder5();
[PreserveSig]
int Placeholder6();
}
}
I created an Instance of IConverterSession.I tried calling methods SetEncoding(), SetSaveFormat() on that instance, these methods are executed successfully. But when I call MIMEToMAPI() on the same instance it gives following exception - "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Here is the code I am using -
Type converter = Type.GetTypeFromCLSID(NativeMethods.CLSID_IConverterSession);
object obj = Activator.CreateInstance(converter);
NativeMethods.IConverterSession session = (NativeMethods.IConverterSession)obj;
int hr = session.SetEncoding(NativeMethods.ENCODINGTYPE.IET_QP);
hr = session.SetSaveFormat(NativeMethods.MIMESAVETYPE.SAVE_RFC822);
if (session != null)
{
Application olApp = new Application();
NameSpace nSpace = olApp.GetNamespace("MAPI");
MailItem msg = (MailItem)olApp.CreateItem(OlItemType.olMailItem);
FileStream stm = File.OpenRead("C:\\e.eml");
hr = session.MIMEToMAPI(stm, msg, null, 0);
msg.Save();
}
I also tried using CoCreateInstance() instead of Activator.CreateInstance() but that also doesn't helped.
Any input on this will be appreciated.
Thanks.
EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com/default.aspx?ref=ng
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
<Sonali Gupta> wrote in message news:200911573929...@gmail.com...