How to create a draft appointment request?

I found how to create a Draft mail message in MSG format, I’d like to create an appointment request but I can’t see a way to do that. Appointment class requires all the parameters and there is no way to make such a MSG draft.


I tried using:

AlternateView.createAlternateViewFromString(“BEGIN:VCALENDAR…”)

but it also requires the sender and recipients to be filled in.

Thanks in advance for any help.

Mariusz

Hi Mariusz,


Thanks for writing to Aspose.Email support team.

I have analyzed the requirement and prepared following sample code for you. It creates an appointment message which is saved as normal and draft both formats. Please give it a try and let us know your feedback.

// create the appointment
Appointment app = new Appointment(“meeting request”, DateTime.Now.AddHours(1), DateTime.Now.AddHours(1.5), "from@aspose.com", "newcustomeronnet@gmail.com");
app.Summary = “meeting request summary”;
app.Description = “description”;

// create the message and set the meeting request
MailMessage msg = new MailMessage();
msg.From = "from@aspose.com";
msg.To = "newcustomeronnet@gmail.com";
msg.TextBody = “Email Message detail”;
msg.Subject = “meeting request”;
msg.AddAlternateView(app.RequestApointment(0));
MapiMessage mapi = MapiMessage.FromMailMessage(msg);

// Set the flag as UNSENT
mapi.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT);
mapi.Save(“AppDraft.msg”);


I already tried that, but it doesn’t open the msg file as Draft, but as a saved, not modifiable appointment. And I don’t want to provide any meeting details in that draft appointment request, I just need to create an empty draft appointment request with some attachments, so the user can open and and provide the details.

Hi Mariusz,


Sorry for a delayed response.

I tried various methods and went over documentation as well to find ways of saving appointment as draft, but couldn’t hit some helpful material in this regard. I have logged your requirement in our issue tracking system as NETWORKNET-33606. Development team will look into it and if this requires some enhancement to the API, it will be implemented. In case we can help you out with some code sample, we will update you here.

Please not that that concerns Java version. Can you let me know how can I track this issue? We plan to purchase Aspose Total in January, but we need to know the status of this by then as we need to let the customer know whether it is possible or not.


Thanks,
Mariusz

Hi Mariusz,


Thank you for sharing your concerns.

I would like to share with you that Aspose.Email for Java is auto-ported version of its .NET equivalent, i.e. once a feature/enhancement is implemented in the .NET version, it is also ported in the Java equivalent. I have logged your requested information against the ticket logged under this thread,and will soon update you after getting information from our development team in this regard.

The issues you have found earlier (filed as NETWORKNET-33606) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

What about Java version? I need that functionality in Java edition. Please let me know when it’s released and how to use it.

Hi Mariusz,


We’ll be releasing Aspose.Email for Java 2.7.0 in a day (or 2). Once the release is in place, I’ll update you via this thread alongwith the link to the method for creating a draft appointment. Your patience till then is appreciated.

Hi Mariusz,


We have released Aspose.Email for Java 2.7.0 that allows you to create an appointment in draft mode. Please refer to the release notes for further details and example.

What if I don’t know the organizer and recipients? Can I leave the leave those two parameters empty?


E.g.
MailMessage message = new MailMessage();
Date startDate = new Date();
Date endDate = new Date();

MailAddressCollection attendees = new MailAddressCollection();
MailAddress organizer = null;
Appointment app = new Appointment("", “”, “”, startDate, endDate, organizer, attendees);
//Set the Appointment as Draft
app.setMethod(AppointmentMethodType.Publish);

message.addAlternateView(app.requestApointment());
MapiMessage mapiMsg = MapiMessage.fromMailMessage(message);
mapiMsg.save(path);

Hi Mariusz,


At present, there is no such relaxation available and entering the Organizer as well as Attendee is necessary. I’ll discuss this with our development team if any such provision can be made available in our next release and will update you here then.

Ah, so it doesn’t actually help it. When a draft appointment is generated I don’t know the recipients, the actual user which will open the appointment needs to fill it in. And the organizer is also not known, it depends how opens the draft.


Anyway, let me know if there is any chance of doing that in a future.

Regards,
Mariusz

I can see that no matter what organizer email is set, when I open the draft appointment it defaults to my account (as the provided organizer email may be not configured), so that is fine. The only enhancement I need in that case is a possibility of leaving recipients empty.

Hi Mariusz,


We have discussed the matter in detail with developers and have logged this issue as enhancement feature. Development team will look into it and will try to provide option to leave recipients empty in the draft appointment. This issue is logged as NETWORKNET-33680 in our issue tracking system.

You will be automatically notified via this forum once the feature is implemented in our future product releases.

Thanks for your patience and understanding.

One more thing. How to add a line break inside the appoinment description? I tried “\n”, “\r\n” or even “
”, but it doesn’t work:(

With “\r\n” the appointment is correctly saved into .ics format - when I open it, the line breaks are preserved, but when it’s converted into a MSG Draft apoinment, I see “\r\n” in the body instead of a line break.

Hi Mariusz,


Please give a try to the following code which converts appointment into MSG draft appointment. This resultant MSG file is opened and line breaks are found preserved. I used “\r” to insert line break in multi-line description of the appointment.

MailMessage message = new MailMessage();
Date startDate = new Date();
Date endDate = new Date();
message.setFrom(new MailAddress("FromUser@domain.com"));
MailAddressCollection attendees = new MailAddressCollection();
attendees.add("ToUser@domain.com");
message.setTo(attendees);
MailAddress organizer = null;
Appointment app = new Appointment(“Location name”, “my summary”, “description1\rdescription2\rdescription3”, startDate, endDate, organizer, attendees);
//Set the Appointment as Draft
app.setMethod(AppointmentMethodType.Publish);
message.addAlternateView(app.requestApointment());
MapiMessage mapiMsg = MapiMessage.fromMailMessage(message);
mapiMsg.save(“AppDraft2.msg”);

A snap shot is attached showing the view of the resultant MS file opened in MS Outlook.

When I run this code from my PC it works fine, when I run it on my server I get a strange exception:


Caused by: java.lang.NullPointerException
at com.aspose.email.Appointment.resetTimeZone(Unknown Source)
at com.aspose.email.Appointment.(Unknown Source)
at com.aspose.email.Appointment.(Unknown Source)
at com.aspose.email.Appointment.(Unknown Source)
at com.aspose.email.Appointment.(Unknown Source)

How can I fix it?

Hi Mariusz,

We are sorry for any inconvenience caused.

Can you please more details about your production environment, as I was unable to reproduce this issue at my end using the latest version of Aspose.Email for Java 2.7.0. Please provide complete information about your server, tomcat installed, and your application. It'll be of added benefit if you could provide us some test project to reproduce this issue at our end, as with my sample code I am unable to reproduce this issue. We'll look into these details and assist you further as soon as possbile.

Hi Mariusz,


Please modify your code as follow to clear the recipients from the MapiMessage at the end. This will serve your needs and save the message in draft mode.


message.addAlternateView(app.requestApointment());


MapiMessage msg = MapiMessage.fromMailMessage(message);


msg.getRecipients().clear();