Sign In  Sign Up Live-Chat

Extracting images from email body

Last post 07-01-2008, 9:43 AM by saqib.razzaq. 3 replies.
Sort Posts: Previous Next
  •  06-30-2008, 3:03 PM 133700

    Extracting images from email body

    Hello

    I am using Aspose.Network.Pop3 and wanted to save images pasted into email bodies into a file on disk.  How can I do this?  The image(s) aren't attachments, they are base 64 encoded into the mail message itself.  Does Aspose have a method to extract these easily or do I need to open the .EML file and load an object with the base 64 data, convert, and write to disk?  A code snippet would be helpful...

    Thanks

    Mike


    This message was posted using Page2Forum from MailMessage Properties - Aspose.Network for .NET
     
  •  07-01-2008, 12:11 AM 133756 in reply to 133700

    Re: Extracting images from email body

    Hello, Mike,

    Do you have chance to check the linkedresources property of the MailMessage? You can load the eml file into a MailMessage class, then get the linked images from the linkedresources collection. Could you provide me a sample eml file to test about it?

    Thanks a lot


    Team Lead
    Aspose Guangzhou Team
    About Us

    Contact Us
     
  •  07-01-2008, 9:18 AM 133818 in reply to 133756

    Re: Extracting images from email body

    Attachment: Present (inaccessible)

    Attached is an .EML file with an embedded picture.  I would like to see C# code to extract it using the LinkedResources collection.

    Thanks

    Mike

     
  •  07-01-2008, 9:43 AM 133829 in reply to 133818

    Re: Extracting images from email body

    Hi Mike,

    The following sample code can extract and save the embedded picture from the eml file.

    MailMessage msg = MailMessage.Load("c:\\temp\\email.eml");

    foreach (LinkedResource resource in msg.LinkedResources)

    {

    // save the attachment to some folder. Filename comes from resource.Name

    resource.Save("c:\\temp\\" + resource.Name);

    }


    Best Regards,

    Saqib Razzaq
    Support Developer
    Aspose Guangzhou Team

     
View as RSS news feed in XML