Save Mailitem as RFC822 with Redemption in C#

H

Hans Schmidt

Hello,

i want to save a mail in a .eml file. Therefore i have following code:

private void buttonCBB_Click(Office.CommandBarButton ctrl, ref bool
cancel)
{
if (selection[1] is Outlook.MailItem)
{
Outlook.MailItem mailItem = selection[1] as Outlook.MailItem;
RDOMail mail = rsession.GetMessageFromID(mailItem.EntryID,
Type.Missing, Type.Missing);

mail.SaveAs(@"c:\test.eml",
Redemption.RedemptionSaveAsType.olRFC822);
}
}

Everything works perfect. In mail i can access everything from
RDOMail.
But if mail.saveas is called nothing happened. If i debug the code der
debugger
doesn't go on, if there is additional code is behind saveas it will
not performed.

Can anybody tell me what i do wrong?


Greets Hans
 
D

Dmitry Streblechenko

How and hwne do you initialize the rsession variable?
Is there a particular reason why you are using RDOMail instead of
SafeMailItem in these particular case?

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

Hans Schmidt

Good Morning,

first of all there is no particular reason, i thought that is the
right way to use RDOMail.
But yesterday evening i tested with SafeMailItem too.

I initialize the rsession variable that way:

public partial class ThisAddIn
{
Outlook.Application applicationObject;
RDOSession rsession;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
applicationObject = Application;
rsession = new RDOSession();
rsession.MAPIOBJECT = applicationObject.Session.MAPIOBJECT;
}
}

After that i tried with SafeMailItem:

Outlook.MailItem mailItem = selection[1] as Outlook.MailItem;
SafeMailItem test = new SafeMailItem();
test.Item = mailItem;
test.SaveAs(@"c:\test.eml", Redemption.RedemptionSaveAsType.olRFC822);

Same effect, nothing happened when calling the SaveAs Method.


Greets Hans



How and hwne do you initialize the rsession variable?
Is there a particular reason why you are using RDOMail instead of
SafeMailItem in these particular case?

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

i want to save a mail in a .eml file. Therefore i have following code:
private void buttonCBB_Click(Office.CommandBarButton ctrl, ref bool
cancel)
{
   if (selection[1] is Outlook.MailItem)
   {
       Outlook.MailItem mailItem = selection[1] as Outlook.MailItem;
       RDOMail mail = rsession.GetMessageFromID(mailItem.EntryID,
Type.Missing, Type.Missing);
       mail.SaveAs(@"c:\test.eml",
Redemption.RedemptionSaveAsType.olRFC822);
   }
}
Everything works perfect. In mail i can access everything from
RDOMail.
But if mail.saveas is called nothing happened. If i debug the code der
debugger
doesn't go on, if there is additional code is behind saveas it will
not performed.
Can anybody tell me what i do wrong?
Greets Hans
 
H

Hans Schmidt

Sorry, the error was that i was not allowed to write to c:\
Now everything works fine.

Thanks for your help.


Greets Hans

Good Morning,

first of all there is no particular reason, i thought that is the
right way to use RDOMail.
But yesterday evening i tested with SafeMailItem too.

I initialize the rsession variable that way:

public partial class ThisAddIn
{
    Outlook.Application applicationObject;
    RDOSession rsession;

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        applicationObject = Application;
        rsession = new RDOSession();
        rsession.MAPIOBJECT = applicationObject.Session.MAPIOBJECT;
    }

}

After that i tried with SafeMailItem:

Outlook.MailItem mailItem = selection[1] as Outlook.MailItem;
SafeMailItem test = new SafeMailItem();
test.Item = mailItem;
test.SaveAs(@"c:\test.eml", Redemption.RedemptionSaveAsType.olRFC822);

Same effect, nothing happened when calling the SaveAs Method.

Greets Hans

How and hwne do you initialize the rsession variable?
Is there a particular reason why you are using RDOMail instead of
SafeMailItem in these particular case?
--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
news:7bd56626-193c-440e-97f3-58c6297a3ae0@b15g2000yqd.googlegroups.com....
Hello,
i want to save a mail in a .eml file. Therefore i have following code:
private void buttonCBB_Click(Office.CommandBarButton ctrl, ref bool
cancel)
{
   if (selection[1] is Outlook.MailItem)
   {
       Outlook.MailItem mailItem = selection[1] as Outlook.MailItem;
       RDOMail mail = rsession.GetMessageFromID(mailItem.EntryID,
Type.Missing, Type.Missing);
       mail.SaveAs(@"c:\test.eml",
Redemption.RedemptionSaveAsType.olRFC822);
   }
}
Everything works perfect. In mail i can access everything from
RDOMail.
But if mail.saveas is called nothing happened. If i debug the code der
debugger
doesn't go on, if there is additional code is behind saveas it will
not performed.
Can anybody tell me what i do wrong?
Greets Hans
 

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