none
Outlook Body Serialization RRS feed

  • Question

  •      I  have a requirement to serialize the open mail as Template and after serialization we need to load the same in new mail content, But also with all the Images(type OlAttachmentType.olOLE) embbeded in the body.

    Till now I have succefully able to save the text part of mailItem with its property Body , RTFBody

    I know images embbeded are shown in MailItem.Attachments.

    But the problem is that I am not able to find the Image which is pasted from RTF document with Type OlAttachmentType.olOLE.

    MY main aim is to get exact copy of any MailItem and serialize it as template(say xml file) and if user want to get start with the same serialize  template then just fully replaced context including images with the serialize MailItem.

     

    One ray of hope was WordOpenXML :

    Outlook.MailItem mailItem = Globals.ThisAddIn.Application.ActiveInspector().CurrentItem as Outlook.MailItem ;

    Word.Document document = mailItem.GetInspector.WordEditor;

    string WordOpenXML = document.WordOpenXML;

     

     

    But is there any way to change the content of new Mailitem with this WordOpenXML

     

    or is there any way?

     

    Please help me.


    Friday, February 3, 2012 6:52 AM

Answers

  • Hi Amit,

     

    Thanks for posting in the MSDN Forum.

     

    I will provide you another way to address your issue: I would recommend you convert your image as a Base64String then embedded it into your email’s HTMLBody. There is the reference for you http://danielmclaren.com/2008/03/embedding-base64-image-data-into-a-webpage.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Monday, February 6, 2012 3:20 AM
    Moderator
  •  

    I have solved this

    1. Outlook.MailItem mailItem = Globals.ThisAddIn. Outlook.MailItem mailItem = Globals.ThisAddIn.Application.ActiveInspector().CurrentItem as Outlook.MailItem;

    Word.Document document = mailItem.GetInspector.WordEditor;

    Word.Range rangeToCopy = doucment.Range();

    String textToCopeXml = rangeToCopy. WordOpenXML;

    2. Now Save textToCopeXml or serialize

     

    3. Now selecte New Email Item by code

       Word.Document doucment =inspector.WordEditor as Word.Document; 

       Word.Range range = doucment.Range();

       range.Delete(); // remove the existing content from new Email Item

       range.InsertXML(textToCopeXml);

    I am just giving the text code, if any problem

    feel free to ask any question.

    Tuesday, March 20, 2012 9:34 AM

All replies

  • Save the message as a template (OFT) either manually (File | Save As) or by calling MailItem.SaveAs(..., olTemplate).

    You can then create a new message from the template by calling Application.CreateItemFromTemplate.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Friday, February 3, 2012 7:03 AM
  • Hi,

     

    Thanks for reply

     

    I have to replace the content of current Mailitem with this type of template(with images)

    how to achieve with that ?

    Is there any scope with Inspector WordEditor which is word document?

    So that we can directly replace the data of current MailItem with some other template data(with Images also)

     

     

     

     

    Friday, February 3, 2012 9:32 AM
  • If you need to import the body into an *existing* item, you can use Redemption and RDOMail/SafeMailItem.Import(..., olMsg).

     


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Friday, February 3, 2012 1:43 PM
  • Hi Amit,

     

    Thanks for posting in the MSDN Forum.

     

    I will provide you another way to address your issue: I would recommend you convert your image as a Base64String then embedded it into your email’s HTMLBody. There is the reference for you http://danielmclaren.com/2008/03/embedding-base64-image-data-into-a-webpage.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Monday, February 6, 2012 3:20 AM
    Moderator
  •  

    I have solved this

    1. Outlook.MailItem mailItem = Globals.ThisAddIn. Outlook.MailItem mailItem = Globals.ThisAddIn.Application.ActiveInspector().CurrentItem as Outlook.MailItem;

    Word.Document document = mailItem.GetInspector.WordEditor;

    Word.Range rangeToCopy = doucment.Range();

    String textToCopeXml = rangeToCopy. WordOpenXML;

    2. Now Save textToCopeXml or serialize

     

    3. Now selecte New Email Item by code

       Word.Document doucment =inspector.WordEditor as Word.Document; 

       Word.Range range = doucment.Range();

       range.Delete(); // remove the existing content from new Email Item

       range.InsertXML(textToCopeXml);

    I am just giving the text code, if any problem

    feel free to ask any question.

    Tuesday, March 20, 2012 9:34 AM