Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Mon, 28 Jul 2008 07:32:44 -0700 (PDT),    group: microsoft.public.platformsdk.mapi        back       


Working with .msg files that are attachments   
Could anybody give me a clue as to how to gain access to .msg files
using MAPI?

I have written an app that the attachment of every email in a mailbox
to a file on disk. These .msg files also contain attachments, how can
I access these?

Alternatively, how could I go about saving these .msg attachments to
another mailbox?

I've got the code in C# if you need it.

Many thanks.
date: Mon, 28 Jul 2008 07:32:44 -0700 (PDT)   author:   airwot4

Re: Working with .msg files that are attachments   
use IConverterSession interface!!!

well I have also developed a similar application!!! Are you coding 
completely in C#? or using VC++ ??

-- 
Regards,
Ashutosh Bhawasinka
email: discussion@ashutosh.in
MCSA - Messaging,
MCTS - .Net Windows Apps


airwot4 wrote:
> Could anybody give me a clue as to how to gain access to .msg files
> using MAPI?
> 
> I have written an app that the attachment of every email in a mailbox
> to a file on disk. These .msg files also contain attachments, how can
> I access these?
> 
> Alternatively, how could I go about saving these .msg attachments to
> another mailbox?
> 
> I've got the code in C# if you need it.
> 
> Many thanks.
date: Mon, 28 Jul 2008 21:18:18 +0530   author:   Ashutosh Bhawasinka

Re: Working with .msg files that are attachments   
Do you mean standalone MSG files or embedded message attachments?

-- 
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-
"airwot4"  wrote in message 
news:85dbfd07-31e3-428a-a4a9-dbe556cfdfc6@26g2000hsk.googlegroups.com...
> Could anybody give me a clue as to how to gain access to .msg files
> using MAPI?
>
> I have written an app that the attachment of every email in a mailbox
> to a file on disk. These .msg files also contain attachments, how can
> I access these?
>
> Alternatively, how could I go about saving these .msg attachments to
> another mailbox?
>
> I've got the code in C# if you need it.
>
> Many thanks.
date: Mon, 28 Jul 2008 09:34:06 -0700   author:   Dmitry Streblechenko

Re: Working with .msg files that are attachments   
#pragma once
//#include <mimeole.h>
#define CCSF_SMTP 				0x0002
#define CCSF_NOHEADERS 			0x0004
#define CCSF_USE_TNEF			0x0010
#define CCSF_INCLUDE_BCC		0x0020
#define CCSF_8BITHEADERS		0x0040
#define CCSF_USE_RTF			0x0080
#define CCSF_PLAIN_TEXT_ONLY 	0x1000
#define CCSF_NO_MSGID 			0x4000
typedef enum tagENCODINGTYPE {
    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
} ENCODINGTYPE;

typedef enum tagMIMESAVETYPE {
    SAVE_RFC822 = 0,
    SAVE_RFC1521 = 1
} MIMESAVETYPE;

DEFINE_GUID(CLSID_IConverterSession, 0x4e3a7680, 0xb77a, 0x11d0, 0x9d, 0xa5, 0x0, 0xc0, 0x4f, 0xd6, 0x56, 0x85);
DEFINE_GUID(IID_IConverterSession, 0x4b401570, 0xb77b, 0x11d0, 0x9d, 0xa5, 0x0, 0xc0, 0x4f, 0xd6, 0x56, 0x85);

interface IConverterSession : IUnknown
{
	virtual STDMETHODIMP SetAdrBook(LPADRBOOK pab);
	virtual STDMETHODIMP SetEncoding (ENCODINGTYPE et);
	virtual STDMETHODIMP IConverterSessionPlaceHolder1();
	virtual STDMETHODIMP MIMEToMAPI (LPSTREAM pstm, LPMESSAGE pmsg, LPCSTR pszSrcSrv, ULONG ulFlags );
	virtual STDMETHODIMP MAPIToMIMEStm(LPMESSAGE pmsg,LPSTREAM pstm, ULONG ulFlags);
	virtual STDMETHODIMP IConverterSessionPlaceHolder2();
	virtual STDMETHODIMP IConverterSessionPlaceHolder3();
	virtual STDMETHODIMP IConverterSessionPlaceHolder4();
	virtual STDMETHODIMP SetTextWrapping (BOOL    fWrapText, ULONG   ulWrapWidth);
	virtual STDMETHODIMP SetSaveFormat (MIMESAVETYPE mstSaveFormat );
	virtual STDMETHODIMP IConverterSessionPlaceHolder5();
	
	virtual STDMETHODIMP IConverterSessionPlaceHolder6();
	//virtual STDMETHODIMP SetCharset(BOOL fApply, HCHARSET hcharset,CSETAPPLYTYPE csetapplytype);
};
date: Mon, 28 Jul 2008 23:26:53 +0530   author:   Ashutosh am

Re: Working with .msg files that are attachments   
Thanks for the responses.

I'm coding entirely in C# for this, I'll look into the
IConverterSession interface but would appreciate any hints/tips.

I'm working with standalong .msg files.

Also, I noticed an application called msgDetach which performs the
required task but I'd prefer not to resort to foreign code in my
solution.

Thanks
date: Thu, 7 Aug 2008 08:59:25 -0700 (PDT)   author:   airwot4

Re: Working with .msg files that are attachments   
IConverterSession  has nothign to do with MSG files, it is used to convert 
to/from MIME format.
What *exactly* are you trying to do with the MSG files?
-- 
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-
"airwot4"  wrote in message 
news:9e52fd4d-cb26-424b-8190-9d80e5d83720@k13g2000hse.googlegroups.com...
> Thanks for the responses.
>
> I'm coding entirely in C# for this, I'll look into the
> IConverterSession interface but would appreciate any hints/tips.
>
> I'm working with standalong .msg files.
>
> Also, I noticed an application called msgDetach which performs the
> required task but I'd prefer not to resort to foreign code in my
> solution.
>
> Thanks
date: Thu, 7 Aug 2008 09:55:37 -0700   author:   Dmitry Streblechenko

Re: Working with .msg files that are attachments   
Use something like [this may not be the best way to. Use it at your own risk]


#define _MSGSESS IMessage
#include <imessage.h>
.
.
.then
 	CComPtr<IMessage> pMessage;
	CComPtr<IStorage> pStorage;
    	LPMSGSESS  pMsgSession =  NULL;
    	LPMSGSESS  pIMsg = NULL;
	HRESULT hRes;
	LPMALLOC pMalloc = MAPIGetDefaultMalloc();
	hRes = ::StgOpenStorage(L"c:\\a.msg",NULL, STGM_READWRITE | STGM_TRANSACTED,NULL,NULL,&pStorage);
	// Open an IMessage interface on an IStorage object
	if(FAILED(hRes) )
		return;
	//TODO: verify that CLSID is CLSID_MailMessage using ReadClassStg

	// Open an IMessage session.
    	hRes = ::OpenIMsgSession(pMalloc, 0, &pMsgSession);
	if(FAILED(hRes) || !pMsgSession)
	{
		Debug(DebugLevel::Error,_T("Error [%#08x] from OpenIMsgSession - %s"),hRes, CMAPIHealper::GetErrorDetails(hRes));
		return ;
	}

    	hRes = ::OpenIMsgOnIStg(pMsgSession, MAPIAllocateBuffer, MAPIAllocateMore, MAPIFreeBuffer, pMalloc, NULL, pStorage, NULL, 0, 0, &pIMsg);
	if(FAILED(hRes) || !pIMsg)
	{
		Debug(DebugLevel::Error,_T("Error [%#08x] from OpenIMsgSession - %s"),hRes, CMAPIHealper::GetErrorDetails(hRes));
		pMsgSession->Release();
		return ;
	}
	CMAPIHealper::DumpProperties(pIMsg);
	//release other interfaces...

-> at this point you have a valid IMessage interface pIMsg, you can retrieve any properties...

I just ran this code and I could see all the properties correctly. Now that you have an IMessage, you can read its content, its attachment in the usual MAPI way.

Hope you can convert this to C#!
-- 
Regards,
Ashutosh Bhawasinka
email: discussion@ashutosh.in
MCSA - Messaging,
MCTS - .Net Windows Apps




airwot4 wrote:
> Thanks for the responses.
>
> I'm coding entirely in C# for this, I'll look into the
> IConverterSession interface but would appreciate any hints/tips.
>
> I'm working with standalong .msg files.
>
> Also, I noticed an application called msgDetach which performs the
> required task but I'd prefer not to resort to foreign code in my
> solution.
>
> Thanks
>
date: Thu, 07 Aug 2008 22:35:25 +0530   author:   Ashutosh Bhawasinka

Re: Working with .msg files that are attachments   
absolutely true!!! I posted that thinking it of MIME format!!

Dmitry Streblechenko wrote:
> IConverterSession  has nothign to do with MSG files, it is used to convert 
> to/from MIME format.
> What *exactly* are you trying to do with the MSG files?
>
date: Thu, 07 Aug 2008 22:40:17 +0530   author:   Ashutosh am

Re: Working with .msg files that are attachments   
Alternatively, if the .msg file is an embedded message (as an attachment 
in a mail), then you need to do these
-Open the .msg file/attachment using IMessage::OpenAttach, here IMessage 
will be of the message containing the .msg file
-Then call IAttach::OpenProperty requesting an IID_IMessage interface
-Now you again have a IMessage, which is of the embedded message, you 
can do anything you do on a normal message.

Ashutosh Bhawasinka wrote:
> Use something like [this may not be the best way to. Use it at your 
> own risk]
>
>
> #define _MSGSESS IMessage
> #include <imessage.h>
> ..
> ..
> ..then
>     CComPtr<IMessage> pMessage;
>     CComPtr<IStorage> pStorage;
>        LPMSGSESS  pMsgSession =  NULL;
>        LPMSGSESS  pIMsg = NULL;
>     HRESULT hRes;
>     LPMALLOC pMalloc = MAPIGetDefaultMalloc();
>     hRes = ::StgOpenStorage(L"c:\\a.msg",NULL, STGM_READWRITE | 
> STGM_TRANSACTED,NULL,NULL,&pStorage);
>     // Open an IMessage interface on an IStorage object
>     if(FAILED(hRes) )
>         return;
>     //TODO: verify that CLSID is CLSID_MailMessage using ReadClassStg
>
>     // Open an IMessage session.
>        hRes = ::OpenIMsgSession(pMalloc, 0, &pMsgSession);
>     if(FAILED(hRes) || !pMsgSession)
>     {
>         Debug(DebugLevel::Error,_T("Error [%#08x] from OpenIMsgSession 
> - %s"),hRes, CMAPIHealper::GetErrorDetails(hRes));
>         return ;
>     }
>
>        hRes = ::OpenIMsgOnIStg(pMsgSession, MAPIAllocateBuffer, 
> MAPIAllocateMore, MAPIFreeBuffer, pMalloc, NULL, pStorage, NULL, 0, 0, 
> &pIMsg);
>     if(FAILED(hRes) || !pIMsg)
>     {
>         Debug(DebugLevel::Error,_T("Error [%#08x] from OpenIMsgSession 
> - %s"),hRes, CMAPIHealper::GetErrorDetails(hRes));
>         pMsgSession->Release();
>         return ;
>     }
>     CMAPIHealper::DumpProperties(pIMsg);
>     //release other interfaces...
>
> -> at this point you have a valid IMessage interface pIMsg, you can 
> retrieve any properties...
>
> I just ran this code and I could see all the properties correctly. Now 
> that you have an IMessage, you can read its content, its attachment in 
> the usual MAPI way.
>
> Hope you can convert this to C#!
date: Thu, 07 Aug 2008 23:09:19 +0530   author:   Ashutosh Bhawasinka

Re: Working with .msg files that are attachments   
On 7 Aug, 18:39, Ashutosh Bhawasinka  wrote:
> Alternatively, if the .msg file is an embedded message (as an attachment
> in a mail), then you need to do these
> -Open the .msg file/attachment using IMessage::OpenAttach, here IMessage
> will be of the message containing the .msg file
> -Then call IAttach::OpenProperty requesting an IID_IMessage interface
> -Now you again have a IMessage, which is of the embedded message, you
> can do anything you do on a normal message.
>
>
>
> Ashutosh Bhawasinka wrote:
> > Use something like [this may not be the best way to. Use it at your
> > own risk]
>
> > #define _MSGSESS IMessage
> > #include <imessage.h>
> > ..
> > ..
> > ..then
> >     CComPtr<IMessage> pMessage;
> >     CComPtr<IStorage> pStorage;
> >        LPMSGSESS  pMsgSession =  NULL;
> >        LPMSGSESS  pIMsg = NULL;
> >     HRESULT hRes;
> >     LPMALLOC pMalloc = MAPIGetDefaultMalloc();
> >     hRes = ::StgOpenStorage(L"c:\\a.msg",NULL, STGM_READWRITE |
> > STGM_TRANSACTED,NULL,NULL,&pStorage);
> >     // Open an IMessage interface on an IStorage object
> >     if(FAILED(hRes) )
> >         return;
> >     //TODO: verify that CLSID is CLSID_MailMessage using ReadClassStg
>
> >     // Open an IMessage session.
> >        hRes = ::OpenIMsgSession(pMalloc, 0, &pMsgSession);
> >     if(FAILED(hRes) || !pMsgSession)
> >     {
> >         Debug(DebugLevel::Error,_T("Error [%#08x] from OpenIMsgSession
> > - %s"),hRes, CMAPIHealper::GetErrorDetails(hRes));
> >         return ;
> >     }
>
> >        hRes = ::OpenIMsgOnIStg(pMsgSession, MAPIAllocateBuffer,
> > MAPIAllocateMore, MAPIFreeBuffer, pMalloc, NULL, pStorage, NULL, 0, 0,
> > &pIMsg);
> >     if(FAILED(hRes) || !pIMsg)
> >     {
> >         Debug(DebugLevel::Error,_T("Error [%#08x] from OpenIMsgSession
> > - %s"),hRes, CMAPIHealper::GetErrorDetails(hRes));
> >         pMsgSession->Release();
> >         return ;
> >     }
> >     CMAPIHealper::DumpProperties(pIMsg);
> >     //release other interfaces...
>
> > -> at this point you have a valid IMessage interface pIMsg, you can
> > retrieve any properties...
>
> > I just ran this code and I could see all the properties correctly. Now
> > that you have an IMessage, you can read its content, its attachment in
> > the usual MAPI way.
>
> > Hope you can convert this to C#!- Hide quoted text -
>
> - Show quoted text -

Thanks for that, the only reason I'm working with standalone .msg
files is because that was the only way MAPI was allowing to to extract
them. They were originally attached to other emails.

I will see how far I get with IMessage.
date: Fri, 8 Aug 2008 04:57:01 -0700 (PDT)   author:   airwot4

Re: Working with .msg files that are attachments   
On 8 Aug, 12:57, airwot4  wrote:
> On 7 Aug, 18:39, Ashutosh Bhawasinka  wrote:
>
>
>
>
>
> > Alternatively, if the .msg file is an embedded message (as an attachment
> > in a mail), then you need to do these
> > -Open the .msg file/attachment using IMessage::OpenAttach, here IMessage
> > will be of the message containing the .msg file
> > -Then call IAttach::OpenProperty requesting an IID_IMessage interface
> > -Now you again have a IMessage, which is of the embedded message, you
> > can do anything you do on a normal message.
>
> > Ashutosh Bhawasinka wrote:
> > > Use something like [this may not be the best way to. Use it at your
> > > own risk]
>
> > > #define _MSGSESS IMessage
> > > #include <imessage.h>
> > > ..
> > > ..
> > > ..then
> > >     CComPtr<IMessage> pMessage;
> > >     CComPtr<IStorage> pStorage;
> > >        LPMSGSESS  pMsgSession =  NULL;
> > >        LPMSGSESS  pIMsg = NULL;
> > >     HRESULT hRes;
> > >     LPMALLOC pMalloc = MAPIGetDefaultMalloc();
> > >     hRes = ::StgOpenStorage(L"c:\\a.msg",NULL, STGM_READWRITE |
> > > STGM_TRANSACTED,NULL,NULL,&pStorage);
> > >     // Open an IMessage interface on an IStorage object
> > >     if(FAILED(hRes) )
> > >         return;
> > >     //TODO: verify that CLSID is CLSID_MailMessage using ReadClassStg
>
> > >     // Open an IMessage session.
> > >        hRes = ::OpenIMsgSession(pMalloc, 0, &pMsgSession);
> > >     if(FAILED(hRes) || !pMsgSession)
> > >     {
> > >         Debug(DebugLevel::Error,_T("Error [%#08x] from OpenIMsgSession
> > > - %s"),hRes, CMAPIHealper::GetErrorDetails(hRes));
> > >         return ;
> > >     }
>
> > >        hRes = ::OpenIMsgOnIStg(pMsgSession, MAPIAllocateBuffer,
> > > MAPIAllocateMore, MAPIFreeBuffer, pMalloc, NULL, pStorage, NULL, 0, 0> > > &pIMsg);
> > >     if(FAILED(hRes) || !pIMsg)
> > >     {
> > >         Debug(DebugLevel::Error,_T("Error [%#08x] from OpenIMsgSession
> > > - %s"),hRes, CMAPIHealper::GetErrorDetails(hRes));
> > >         pMsgSession->Release();
> > >         return ;
> > >     }
> > >     CMAPIHealper::DumpProperties(pIMsg);
> > >     //release other interfaces...
>
> > > -> at this point you have a valid IMessage interface pIMsg, you can
> > > retrieve any properties...
>
> > > I just ran this code and I could see all the properties correctly. Now
> > > that you have an IMessage, you can read its content, its attachment in
> > > the usual MAPI way.
>
> > > Hope you can convert this to C#!- Hide quoted text -
>
> > - Show quoted text -
>
> Thanks for that, the only reason I'm working with standalone .msg
> files is because that was the only way MAPI was allowing to to extract
> them. They were originally attached to other emails.
>
> I will see how far I get with IMessage.- Hide quoted text -
>
> - Show quoted text -

I've had little luck with this so far, I was hoping to find some C#
examples of this interface being used but have been unable to. I have
little experience of working with interfaces so don't think I'll be
able to muddle through this until I do, is there any resources you
could recommend for reading up on this?
date: Fri, 8 Aug 2008 05:40:37 -0700 (PDT)   author:   airwot4

Re: Working with .msg files that are attachments   
What exactly you are trying to do??
I guess you already have the code in C# to read open the message and its 
attachment!! So, if you tell us where you are stuck, maybe we can help.

If you are using functions like StgOpenStorage, OpenIMsgSession, 
OpenIMsgOnIStg, you can use P/Invoke
date: Fri, 08 Aug 2008 20:24:23 +0530   author:   Ashutosh Bhawasinka

Re: Working with .msg files that are attachments   
On 8 Aug, 15:54, Ashutosh Bhawasinka  wrote:
> What exactly you are trying to do??
> I guess you already have the code in C# to read open the message and its
> attachment!! So, if you tell us where you are stuck, maybe we can help.
>
> If you are using functions like StgOpenStorage, OpenIMsgSession,
> OpenIMsgOnIStg, you can use P/Invoke

I'm using the Microsoft.Office.Interop.Outlook library to end up with
an Outlook.Attachment from a message. The only function I can find to
do this is Attachment.SaveAsFile. As I am working with a message
attached to a message this saves the .msg file to disk. I would like
to be able to create a Outlook._MailItem from the .msg file in order
to extract the attachment from that.
date: Mon, 11 Aug 2008 04:02:42 -0700 (PDT)   author:   airwot4

Re: Working with .msg files that are attachments   
Here is the source code I am using to extract the .msg files.
'emailbox' is the source inbox and 'output' is the directory where
the .msg files will be stored.

    private static void EnumerateInbox(string emailbox, string output)
        {
            Outlook._Application oApp = new Outlook.Application();
            Outlook.NameSpace oNS = oApp.GetNamespace("MAPI");

            try { oNS.Logon(null, null, false, false); }
            catch (Exception ex)
{ Console.WriteLine(ex.Message); }

            Outlook.Recipient oRecipient =
oNS.CreateRecipient(emailbox);
            Outlook.MAPIFolder folder =
oNS.GetSharedDefaultFolder(oRecipient,
Outlook.OlDefaultFolders.olFolderInbox);
            Outlook.Items items = folder.Items;

            for (int i = items.Count; i >= 1; i--)
            {
                try
                {
                    Outlook._MailItem mailitem =
(Outlook._MailItem)items[i];
                    Outlook.Attachments atts =
(Outlook.Attachments)mailitem.Attachments;
                    Outlook.Attachment att =
(Outlook.Attachment)atts[1];

                    att.SaveAsFile(output +
mailitem.CreationTime.ToFileTimeUtc() + " " + att.FileName);

                    mailitem.UnRead = false;
                    mailitem = null;
                    atts = null;
                    att = null;
                }
                catch (Exception ex) {Console.WriteLine("Error
extracting item " + i + ": " + ex.Message); }
            }
        }
date: Mon, 11 Aug 2008 04:06:01 -0700 (PDT)   author:   airwot4

Re: Working with .msg files that are attachments   
If you are using OOM, the only way to import MSG file is to call 
Application.CreateItemFromTemplate.
<plug>
Redemption (url below) supports both opening the standalone MSG files (see 
RDOSession.GetMessageFromMsgFIle) and importing the contents of any MSG file 
using RDOMail.Import.
</plug>

-- 
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-
"airwot4"  wrote in message 
news:49167791-358d-4a4c-b7d2-a4ba08534d54@d1g2000hsg.googlegroups.com...
> On 8 Aug, 15:54, Ashutosh Bhawasinka  wrote:
>> What exactly you are trying to do??
>> I guess you already have the code in C# to read open the message and its
>> attachment!! So, if you tell us where you are stuck, maybe we can help.
>>
>> If you are using functions like StgOpenStorage, OpenIMsgSession,
>> OpenIMsgOnIStg, you can use P/Invoke
>
> I'm using the Microsoft.Office.Interop.Outlook library to end up with
> an Outlook.Attachment from a message. The only function I can find to
> do this is Attachment.SaveAsFile. As I am working with a message
> attached to a message this saves the .msg file to disk. I would like
> to be able to create a Outlook._MailItem from the .msg file in order
> to extract the attachment from that.
date: Mon, 11 Aug 2008 11:53:17 -0700   author:   Dmitry Streblechenko

Re: Working with .msg files that are attachments   
On 11 Aug, 19:53, "Dmitry Streblechenko"  wrote:
> If you are using OOM, the only way to import MSG file is to call
> Application.CreateItemFromTemplate.
> <plug>
> Redemption (url below) supports both opening the standalone MSG files (see
> RDOSession.GetMessageFromMsgFIle) and importing the contents of any MSG file
> using RDOMail.Import.
> </plug>
>
> --
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> OutlookSpy  - Outlook, CDO
> and MAPI Developer Tool
> -"airwot4"  wrote in message
>
> news:49167791-358d-4a4c-b7d2-a4ba08534d54@d1g2000hsg.googlegroups.com...
>
>
>
> > On 8 Aug, 15:54, Ashutosh Bhawasinka  wrote:
> >> What exactly you are trying to do??
> >> I guess you already have the code in C# to read open the message and its
> >> attachment!! So, if you tell us where you are stuck, maybe we can help> >> If you are using functions like StgOpenStorage, OpenIMsgSession,
> >> OpenIMsgOnIStg, you can use P/Invoke
>
> > I'm using the Microsoft.Office.Interop.Outlook library to end up with
> > an Outlook.Attachment from a message. The only function I can find to
> > do this is Attachment.SaveAsFile. As I am working with a message
> > attached to a message this saves the .msg file to disk. I would like
> > to be able to create a Outlook._MailItem from the .msg file in order
> > to extract the attachment from that.- Hide quoted text -
>
> - Show quoted text -

That's great, thank you. Redemption made it very easy.
date: Tue, 12 Aug 2008 04:55:16 -0700 (PDT)   author:   airwot4

Re: Working with .msg files that are attachments   
Hi,
I am using RDOSession.GetMessageFromMsgFIle to get RDOMail. I am having 2 
attachments in this Mail. Once I get the names of the attachments, I am not 
able to use the attachments again. I am getting exception "Error in 
IMessage.OpenAttach: MAPI_E_NO_ACCESS". Can anybody please help me.

Thanks,
Zaheer

"Dmitry Streblechenko" wrote:

> If you are using OOM, the only way to import MSG file is to call 
> Application.CreateItemFromTemplate.
> <plug>
> Redemption (url below) supports both opening the standalone MSG files (see 
> RDOSession.GetMessageFromMsgFIle) and importing the contents of any MSG file 
> using RDOMail.Import.
> </plug>
> 
> -- 
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy  - Outlook, CDO
> and MAPI Developer Tool
> -
> "airwot4"  wrote in message 
> news:49167791-358d-4a4c-b7d2-a4ba08534d54@d1g2000hsg.googlegroups.com...
> > On 8 Aug, 15:54, Ashutosh Bhawasinka  wrote:
> >> What exactly you are trying to do??
> >> I guess you already have the code in C# to read open the message and its
> >> attachment!! So, if you tell us where you are stuck, maybe we can help.
> >>
> >> If you are using functions like StgOpenStorage, OpenIMsgSession,
> >> OpenIMsgOnIStg, you can use P/Invoke
> >
> > I'm using the Microsoft.Office.Interop.Outlook library to end up with
> > an Outlook.Attachment from a message. The only function I can find to
> > do this is Attachment.SaveAsFile. As I am working with a message
> > attached to a message this saves the .msg file to disk. I would like
> > to be able to create a Outlook._MailItem from the .msg file in order
> > to extract the attachment from that. 
> 
> 
>
date: Fri, 3 Oct 2008 08:34:05 -0700   author:   Zaheer Syed Zaheer

Re: Working with .msg files that are attachments   
Messages created MSG files created on top of MSG files won't let you reopen 
the attachmeent table (IMesage::GetAttachmentTable until your release the 
first instance.
Cache the returned from RDOMail.Attachments and do nto use multipel dot 
notation:

set Attachments = YourRDOMail.Attachments
if Attachments.Count > 0 Then
  MsgBox Attachments.Items(i).FileName
End If
set Attachments = Nothing 'release it

-- 
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-
"Zaheer Syed" <Zaheer Syed@discussions.microsoft.com> wrote in message 
news:D1AA1825-4F06-4A7A-A500-7520A2FDC89B@microsoft.com...
> Hi,
> I am using RDOSession.GetMessageFromMsgFIle to get RDOMail. I am having 2
> attachments in this Mail. Once I get the names of the attachments, I am 
> not
> able to use the attachments again. I am getting exception "Error in
> IMessage.OpenAttach: MAPI_E_NO_ACCESS". Can anybody please help me.
>
> Thanks,
> Zaheer
>
> "Dmitry Streblechenko" wrote:
>
>> If you are using OOM, the only way to import MSG file is to call
>> Application.CreateItemFromTemplate.
>> <plug>
>> Redemption (url below) supports both opening the standalone MSG files 
>> (see
>> RDOSession.GetMessageFromMsgFIle) and importing the contents of any MSG 
>> file
>> using RDOMail.Import.
>> </plug>
>>
>> -- 
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy  - Outlook, CDO
>> and MAPI Developer Tool
>> -
>> "airwot4"  wrote in message
>> news:49167791-358d-4a4c-b7d2-a4ba08534d54@d1g2000hsg.googlegroups.com...
>> > On 8 Aug, 15:54, Ashutosh Bhawasinka  wrote:
>> >> What exactly you are trying to do??
>> >> I guess you already have the code in C# to read open the message and 
>> >> its
>> >> attachment!! So, if you tell us where you are stuck, maybe we can 
>> >> help.
>> >>
>> >> If you are using functions like StgOpenStorage, OpenIMsgSession,
>> >> OpenIMsgOnIStg, you can use P/Invoke
>> >
>> > I'm using the Microsoft.Office.Interop.Outlook library to end up with
>> > an Outlook.Attachment from a message. The only function I can find to
>> > do this is Attachment.SaveAsFile. As I am working with a message
>> > attached to a message this saves the .msg file to disk. I would like
>> > to be able to create a Outlook._MailItem from the .msg file in order
>> > to extract the attachment from that.
>>
>>
>>
date: Mon, 6 Oct 2008 15:01:58 -0700   author:   Dmitry Streblechenko

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us