DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone >

Create & Save an Appointment in Draft Mode inside Java Applications

David Zondray user avatar by
David Zondray
·
May. 07, 14 · · Code Snippet
Like (0)
Save
Tweet
1.81K Views

Join the DZone community and get the full member experience.

Join For Free
This technical tip shows how Java developers can create and save an appointment in draft mode inside their own applications using Aspose.Email for Java. It can be useful to create an appointment request in draft mode, so that the basic information is added and then the same draft appointment can be forwarded to other users who might make changes. Aspose.Email for Java provides the flexibility to create and save an appointment in draft mode for later use. In order to save an appointment in draft mode, the Method property of the Appointment class should be set to Publish. The following code sample demonstrates the use of this property as an example.
//Create a Draft Appointment Request
 
String sender = "test@gmail.com";
String recipient = "test@email.com";

MailMessage message = new MailMessage(sender, recipient, "", "");

Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
calendar.set(2012, Calendar.NOVEMBER, 1, 0, 0, 0);
Date startDate = calendar.getTime();
calendar.set(2012, Calendar.DECEMBER, 1);
Date endDate = calendar.getTime();

MailAddressCollection attendees = new MailAddressCollection();
attendees.add(new MailAddress("attendee_address@aspose.com", "Attendee"));
WeeklyRecurrencePattern expected = new WeeklyRecurrencePattern(3);

Appointment app = new Appointment("Appointment Location", "Appointment Summary", "Appointment Description",
        startDate, endDate,
        new MailAddress("organizer_address@aspose.com", "Organizer"), attendees, expected);

//Set the Appointment as Draft
app.setMethod(AppointmentMethodType.Publish);//.Method = AppointmentMethodType.Publish;
message.addAlternateView(app.requestApointment());
MapiMessage msg = MapiMessage.fromMailMessage(message);

// Save the appointment as draft.
msg.save("Draft.msg");

//Draft Appointment Creation from Text
 
String ical = "BEGIN:VCALENDAR\r\nMETHOD:PUBLISH\r\nPRODID:-//Aspose Ltd//iCalender Builder (v3.0)//EN\r\nVERSION:2.0\r\nBEGIN:VEVENT\r\nATTENDEE;CN=test@gmail.com:mailto:test@gmail.com\r\nDTSTART:20130220T171439\r\nDTEND:20130220T174439\r\nDTSTAMP:20130220T161439Z\r\nEND:VEVENT\r\nEND:VCALENDAR";

String sender = "test@gmail.com";
String recipient = "test@email.com";

MailMessage message = new MailMessage(sender, recipient, "", "");

AlternateView av = AlternateView.createAlternateViewFromString(ical, new ContentType("text/calendar"));

message.getAlternateViews().add(av);

MapiMessage msg = MapiMessage.fromMailMessage(message);

// Save the appointment as draft.
msg.save("DraftAppointment.msg");

Java (programming language) application

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Testing Under the Hood Or Behind the Wheel
  • 10 Steps to Become an Outstanding Java Developer
  • How To Use Cluster Mesh for Multi-Region Kubernetes Pod Communication
  • JUnit 5 Tutorial: Nice and Easy [Video]

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo