Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JMSG
>
Tutorial
> Create message
The following example shows you how to create a message.
import java.io.IOException; import com.independentsoft.msg.DisplayType; import com.independentsoft.msg.Message; import com.independentsoft.msg.MessageFlag; import com.independentsoft.msg.ObjectType; import com.independentsoft.msg.Recipient; import com.independentsoft.msg.RecipientType; import com.independentsoft.msg.StoreSupportMask; public class Example { public static void main(String[] args) { try { Message message = new Message(); Recipient recipient1 = new Recipient(); recipient1.setAddressType("SMTP"); recipient1.setDisplayType(DisplayType.MAIL_USER); recipient1.setObjectType(ObjectType.MAIL_USER); recipient1.setDisplayName("John Smith"); recipient1.setEmailAddress("John@domain.com"); recipient1.setRecipientType(RecipientType.TO); Recipient recipient2 = new Recipient(); recipient2.setAddressType("SMTP"); recipient2.setDisplayType(DisplayType.MAIL_USER); recipient2.setObjectType(ObjectType.MAIL_USER); recipient2.setDisplayName("Mary Smith"); recipient2.setEmailAddress("Mary@domain.com"); recipient2.setRecipientType(RecipientType.CC); message.setSubject("Test"); message.setBody("Body text"); message.setDisplayTo("John Smith"); message.setDisplayCc("Mary Smith"); message.getRecipients().add(recipient1); message.getRecipients().add(recipient2); message.getMessageFlags().add(MessageFlag.UNSENT); message.getStoreSupportMasks().add(StoreSupportMask.CREATE); message.save("c:\\temp\\message.msg", true); } catch (IOException e) { e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*