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

Free Support Forum - aspose.com

How to set Time Zone in Appointment in PST File using Aspose.Email for java API

Hello Team ,


I have a issue with setting a time zone property.My time zone string is “Asia/Calcutta Chennai, Kolkata, Mumbai, New Delhilike this.Please send me some sample code to set Time Zone.

My Sample code is below

//*************

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #4e9072} p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3933ff} span.s1 {color: #931a68} span.s2 {color: #0326cc} span.s3 {color: #3933ff} span.s4 {color: #000000} span.s5 {text-decoration: underline} span.Apple-tab-span {white-space:pre}

MailAddressCollection attendees = new MailAddressCollection();

attendees.addMailAddress(new MailAddress(p_AppointmentObj.m_To, "Attendee"));

Appointment app = new Appointment(f_Location, startDate, endByDate, new MailAddress(p_AppointmentObj.m_Organizer, "Organizer"), attendees);

//"Asia/Calcutta Chennai, Kolkata, Mumbai, New Delhi"

app.setTimeZone("Asia/Calcutta Chennai, Kolkata, Mumbai, New Delhi");

MailMessage msg = new MailMessage();

msg.addAlternateView(app.requestApointment());

MapiMessage mapi = MapiMessage.fromMailMessage(msg);

f_MapiCalendarObj = (MapiCalendar) mapi.toMapiMessageItem();



//********

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #4e9072} span.s1 {text-decoration: underline}

Hi Ajinath,

Thank you for contacting Aspose Support team.

Appointment.setTimezone expects a standard timezone string in the format “America/New_York”. Please try using Asia/Calcutta as timezone string in your case as mentioned below:


java.util.Calendar startDate = java.util.Calendar.getInstance();
startDate.set(
2017, 0, 31);
java.util.Calendar endDate = java.util.Calendar.getInstance();
endDate.set(
2017, 1, 5);

MailAddressCollection attendees =
new MailAddressCollection();

attendees.addMailAddress(
new MailAddress("attendee@domain.com", "Attendee"));
Appointment app =
new Appointment("location", startDate.getTime(), endDate.getTime(), new MailAddress("organizer@domain.com", "Organizer"), attendees);
//"Asia/Calcutta Chennai, Kolkata, Mumbai, New Delhi"
app.setTimeZone("Asia/Calcutta");

MailMessage msg =
new MailMessage();
msg.addAlternateView(app.requestApointment());
MapiMessage mapi = MapiMessage.fromMailMessage(msg);


Please try the above at your end and let us know your feedback.

Hello Team,
In my case some times Attendees and Oraganizer fields are null or empty. So how to create Appointment object. If i create it gives me exception as null pointer exception. i am using previous code.

Appointment app = new Appointment(f_Location, startDate, endByDate, new MailAddress(p_AppointmentObj.m_Organizer, “Organizer”), attendees);

app.setTimeZone(“Asia/Calcutta”);

Please help me…

@kharade.a,

Currently there is no such option available where organizer and attendees can be left blank. You may set some predefined dummy organizer and attendee which can be later replaced when required. Please feel free to write us back if you have any other query in this regard.