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

Free Support Forum - aspose.com

Licence watermark issue on converted emails (JAVA)

Hi,


I am running a JEE app that uses Aspose as part of a static pojo to convert mail, images, documents etc. I have the Aspose.Total licence and it works perfectly for PDF, Words and Cells but for Email for some reason the first email that gets converted to PDF always has the Aspose watermarks on it. Every mail converted after the fact is fine. As the class is static you are guaranteed that the static block is called and I even checked that it is being set. I have attached a code snippet so you can get an idea what I am trying to do. I have tried this with the 4.2.0 - 4.4.0 version of Aspose.Email

Hi Eugene,


Thank you for contacting Aspose support team.

I have analyzed your code and tried to re-produce the issue by using your sample code snippet in my project, however am afraid to share that I could not re-produce it. Following is the sample code which uses the sample functions provided by you but all the output files are ok and no watermarks are present there. Could you please send us a complete project which can be used here to re-produce the scenario?

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.Date;
import java.util.TimeZone;
import com.aspose.email.MailMessage;
import com.aspose.email.MailMessageSaveType;
import com.aspose.words.LoadFormat;
import com.aspose.words.LoadOptions;
import com.aspose.words.PdfSaveOptions;
import com.aspose.words.SaveFormat;
import com.aspose.words.SaveOptions;

public class AppMain
{
/**
* @param args
/
private static void setLicense()
{
try
{
// Set license. Provide full path and license file name
com.aspose.email.License licEmail = new com.aspose.email.License();
licEmail.setLicense(“E:\License\Aspose.Total.Product.Family.lic”);
com.aspose.words.License licWords = new com.aspose.words.License();
licWords.setLicense(“E:\License\Aspose.Total.Product.Family.lic”);
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
}
public static void main(String[] args)
{
setLicense();
MailMessage mail = MailMessage.load(“D:/Aspose/Email line space test.msg”);
com.aspose.words.Document doc = convertEmailToDocument(mail);
convertEmailToContent(mail);
SaveOptions options = SaveOptions.createSaveOptions(SaveFormat.DOC);
try {
doc.save(“D:/Aspose/Email line space test.doc”, options);

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(“Processed”);
}
public static com.aspose.words.Document convertEmailToDocument(MailMessage msg)
{
try
{
LoadOptions loadOptions = new LoadOptions();
loadOptions.setLoadFormat(LoadFormat.TEXT);
String body = msg.getBody();
if (msg.isBodyHtml())
{
loadOptions.setLoadFormat(LoadFormat.HTML);
body = msg.getHtmlBody();
}
InputStream is = new ByteArrayInputStream(body.getBytes());
com.aspose.words.Document wordsDoc = new com.aspose.words.Document(is, loadOptions);
return wordsDoc;
}
catch (Exception e)
{
throw new RuntimeException(“Failed to convert email to document”, e);
}
}
private static void convertEmailToContent(MailMessage msg/, FileContent content*/)
{
try
{
TimeZone tz = TimeZone.getDefault();
msg.setTimeZoneOffset(tz.getOffset(new Date().getTime()));
ByteArrayOutputStream mHtmlOutputStream = new ByteArrayOutputStream();
msg.save(mHtmlOutputStream, MailMessageSaveType.getMHtmlFormat());
InputStream mHtmlInputStream = new ByteArrayInputStream(mHtmlOutputStream.toByteArray());
LoadOptions loadOptions = new LoadOptions();
loadOptions.setLoadFormat(LoadFormat.MHTML);
com.aspose.words.Document mhtmlDocument = new com.aspose.words.Document(mHtmlInputStream, loadOptions);
ByteArrayOutputStream pdfOs = new ByteArrayOutputStream();
mhtmlDocument.save(pdfOs, new PdfSaveOptions());
mhtmlDocument.save(“D:/Aspose/Email line space test.mhtml”, SaveFormat.MHTML);
}
catch(Exception ex)
{
}
}
}