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

Free Support Forum - aspose.com

First Application using APOSE.email is giving compilation error

Hi,


I am using Net Beans 6.9.1 and added apose jar files and created a sample program.
It is giving my compilation error. Can some please suggest where I am wrong. Below is my sample Program.

package missingsequence;

import com.aspose.email.MailAddress;
import com.aspose.email.MailAddressCollection;
import com.aspose.email.MailMessage;
import com.aspose.email.MailMessageSaveType;
import com.aspose.email.system.io.MemoryStream;
public class MissingSequence {
public static void main(String[] args) {
String strBaseFolder = “C:\Lap_C_Drive\APOSEMAILS”;
System.out.println(“Creating new messages…”);

MailMessage message = new MailMessage();
message.setFrom(new MailAddress("atul.bhadauria@xchanging.com", “Atul Singh”, false));
//Compilation ERROR
message.getTo().add(new MailAddress("atul.bhadauria@xchanging.com", “Atul Singh”));
message.getTo().add(new MailAddress("atuls.work@gmail.com", “ATUL2”, false));
//*******************************
message.setSubject(“New message created by Aspose.Email for Java”);

message.setHtmlBody("This line is in bold.

" +
“This line is in blue color”);
//Compilation Error while message save(Illegal Argument**********
message.save(strBaseFolder + “Message.eml”, MailMessageSaveType.getEmlFormat());
message.save(strBaseFolder + “Message.msg”, MailMessageSaveType.getOutlookMessageFormat());
message.save(strBaseFolder + “Message.mhtml”, MailMessageSaveType.getMHtmlFromat());
//********************************************
System.out.println(“Messages created successfuly”);
}
}

Not able to understand the reason. I have simple copied it from site and changed values only as per my need. Can someone please suggest.
I have also attached the screen print so that a description of compilation error can be shown.

Regards
Atul

Hi Atul,

Thank you for contacting Aspose Support team.

Please use the following sample code to get started with the API. We have updated the documentation sample to the latest API code for reference. Please try the code at your end and let us know your feedback if you face some problem.

Sample Code:

String strBaseFolder = “C:\Lap_C_Drive\APOSEMAILS”;
System.out.println(“Creating new messages…”);

MailMessage message = new MailMessage();

message.setFrom(new MailAddress("atul.bhadauria@xchanging.com", “Atul Singh”, false));

message.getTo().addItem(new MailAddress("atul.bhadauria@xchanging.com", “Atul Singh”));
message.getTo().addItem(new MailAddress("atuls.work@gmail.com", “ATUL2”, false));
message.setSubject(“New message created by Aspose.Email for Java”);

message.setHtmlBody("This line is in bold.

" +
“This line is in blue color”);

message.save(strBaseFolder + “Message.eml”, SaveOptions.getDefaultEml());
message.save(strBaseFolder + “Message.msg”, SaveOptions.getDefaultMsg());
message.save(strBaseFolder + “Message.mhtml”, SaveOptions.getDefaultMhtml());

System.out.println(“Messages created successfuly”);

Thank you so much.

The updated code has worked successfully. However I request you to please update the document at other places also because it will be helpful in future.


Hi Atul,

Thank you for your feedback. We update the documentation from time to time with every release. One such activity is currently under process to update obsolete code samples. Please feel free to contact us in case you have any further query related to the API.