We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Conversion of Email to PDF

We are trying to convert emails to PDF using Aspose.Email and Aspose.Words APIs, but images in message body are not coming in output. Is there any way to get those in output pdf?

@Acton,

Thank you for contacting Aspose support team.

There are different options to handle images in the body. If EML contains inline images, it is treated in a different way whereas if images are embedded in message body via internal URLs, then Aspose.Email doesn’t fetch these images from web during conversion to MHTML.

It is Aspose.Words API that fetches the image data from internet during loading MHTML file and will display images in output PDF if you are connected to internet. Otherwise, in case of no connectivity, the output PDF will be missing the images. Please analyze your sample message and share your feedback.

If the sample message has inline images, please use following sample code to display the images in the body while converting it to PDF.

public static bool ConvertEml(string inputfile, string outputFile)
{
    MailMessage message = MailMessage.Load(inputfile);
    message.TimeZoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(message.Date);
    MhtSaveOptions mhtSaveOptions = new MhtSaveOptions
    {
        MhtFormatOptions = MhtFormatOptions.WriteHeader | MhtFormatOptions.WriteCompleteEmailAddress
    };
    mhtSaveOptions.SkipInlineImages = false;
    MemoryStream msgStream = new MemoryStream();
    message.Save(msgStream, mhtSaveOptions);
    msgStream.Position = 0;
    var options = new Aspose.Words.LoadOptions()
    {
        LoadFormat = Aspose.Words.LoadFormat.Mhtml
    };
    var document = new Aspose.Words.Document(msgStream, options);
    document.Save(outputFile, Aspose.Words.SaveFormat.Pdf);
    return true;
}

Hi,
Confirmation-Using aspose email we have method to read inbox mail(ImapFolderInfo.IN_BOX) at the same time am looking for sent items,failed to find the same inbuilt method for sent email read functionality .
Requirement:
I want to read mail from sent item as same like inbox given above for refer. Waiting for respose

@Abdul_wajeed,

You may use the code snippet given below to select the sent items folder.

//For Gmail
 imapClient.SelectFolder("[Gmail]/Sent Mail");
//For office365
imapClient.SelectFolder("Sent Items");

We hope that this answered your question. Please feel free to contact us if additional information is required.

@muhammadahmad:

AsposeException.png (6.0 KB)

without cc and bcc we trying to send email through aspose email api from JAVA. we are getting Exception i,e com.aspose.email.system.exceptions.ArugmentException: The parameter address cant be empty string.

How to handle this? Is this is a limitation from aspose email api? PLease response ASAP

@Abdul_wajeed,

You may use the code snippet given below to send an email.

SmtpClient smtpClient = new SmtpClient();
smtpClient.setHost("smtp.gmail.com");
smtpClient.setUsername("EmailAddress");
smtpClient.setPassword("Password");
smtpClient.setPort(587);
smtpClient.setSecurityOptions(SecurityOptions.SSLExplicit);

MailMessage mailMessage = new MailMessage("EmailAddress", "EmailAddress2", "Test Email", "Test Email Body");
smtpClient.send(mailMessage);
smtpClient.dispose();

We hope that this resolved the issue you were facing. If the issue still persists, please provide us the sample code that you used so that we can assist you further. Please also make sure that you are using the latest version of Aspose.Email for Java API.

@muhammadahmad:
How to read sent email data using aspose email with STMPCLIENT? Sample code snippet.

@Abdul_wajeed,

You may retrieve the emails using POP3 Client or IMAP Client. You may find additional information and code samples in the links given below.

We hope that this answered your question. Please feel free to reach us if additional information is required.