You need to sign in to do that
Don't have an account?

I should probably have posted here... - Apex and ICS meeting requests
Hello,
I'm a new user with a devil of a problem - I need to create a bit of code that wil allow me to send meeting requests to non-Salesforce users that will put my Salesforce meetings in their diaries, Outlook or other.
I put full details of my request on the General board, thinking it could be done from within the custom HTML email templates. I now realise it's more of an Apex issue.
Would you be so kind as to take a look? The thread is http://boards.developerforce.com/t5/General-Development/sending-an-ICS-Outlook-compatible-calendar-request-with-workflow/td-p/658603.
Best regards,
Alex.
Alex - Finally been able to get something working for you.. Of course need further belts and braces but let me know how this goes....
Just using plain text content here but can easily expand to use HTML in email and attachment.
Do mark this as a solution so that it helps other looking around.
All Answers
Alex - Finally been able to get something working for you.. Of course need further belts and braces but let me know how this goes....
Just using plain text content here but can easily expand to use HTML in email and attachment.
Do mark this as a solution so that it helps other looking around.
Dear VBS,
Thank you so much for this! Apologies, I have been in meetings all day and only just found the email. I can't wait to check this out - will report back shortly.
I really appreciate you taking the trouble to help me.
Have a great weekend and best regards,
Alex.
Dear VBS,
Frustratingly, for reasons I don't understand, the post you kindly put here yesterday has disappeared, along with my responses.
Could you possibly repost the updated code you created please?
For the record (i.e. for people who are searching this in future who need to understand the thread) what I put here yesterday which you responded to was this:
"
Once again, many thanks for your help with this.
Two problems, both of which are due to my inexperience.
Firstly, I now realise that I need to write an Apex trigger to accompany this.
I'd like the trigger to be an After trigger, which fires when the Opportunity Stage is advanced to "StageName 2. Pitch team/rehearsals confirmed"
Secondly, I'm not quite sure how to personalise the code you have so kindly written.
For the date/time of the meeting, I'd like the code to use the custom date/time field I have created "First_Meeting__c"
The recipients should be
$User.Email
Plus three Opportunity custom email fields
"IPA_Pitch_Member_1__c"
"IPA_Pitch_Member_1__c"
"IPA_Pitch_Member_1__c"
I'd also like to be able to cc cc'd to richard.patient@indigopa.com and alex,ritson@indigopa.com
Please could you help me with this? Thank you in advance - I am tremendously grateful.
public static void Sendmail_With_IcsAttachment(DateTime startDate, DateTime endDate, String location, String body, String subject, String fromAddress, String displayName, List<String> toAddress, List<String> ccAddress)
{ String attachmentName = 'Meeting.ics';
Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
//Now we have to set the value to Mail message properties
//Note Please change it to correct mail-id to use this in your application
msg.setReplyTo(fromAddress);
msg.setSenderDisplayName(displayName);
msg.setToAddresses(toAddress);
msg.setCcAddresses(ccAddress);
// it is optional, only if required
msg.setSubject(subject);
msg.setPlainTextBody(body);
// Create the attachment
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName(attachmentName );
Blob b = doIcsAttachment(startDate, endDate, location, body, subject, fromAddress, displayName, toAddress);
efa.setBody(b);
msg.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
// Send the email you have created.
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { msg });
}
private static Blob doIcsAttachment(DateTime startDate, DateTime endDate, String location, String body, String subject, String fromAddress, String displayName, String toAddress)
{
// Now Contruct the ICS file
String [] icsTemplate = new List<String>
{'BEGIN:VCALENDAR', 'PRODID:-//Schedule a Meeting', 'VERSION:2.0', 'METHOD:REQUEST', 'BEGIN:VEVENT', 'DTSTART: ' + String.valueof(startDate), 'DTSTAMP: '+ String.valueof(DateTime.Now()), 'DTEND: ' + String.valueof(endDate), 'LOCATION: ' + location, 'UID: ' + String.valueOf(Crypto.getRandomLong()), 'DESCRIPTION: ' + body, 'X-ALT-DESC;FMTTYPE=text/html: ' + body, 'SUMMARY: ' + subject, 'ORGANIZER:MAILTO: ' + fromAddress, 'ATTENDEE;CN="' + displayName + '";RSVP=TRUE:mailto: ' + toAddress, 'BEGIN:VALARM', 'TRIGGER:-PT15M', 'ACTION:DISPLAY', 'DESCRIPTION:Reminder', 'END:VALARM', 'END:VEVENT', 'END:VCALENDAR' };
String attachment = String.join(icsTemplate, '\n');
return Blob.valueof(attachment );
}
}
See my post for more details: https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AsPlIAK
Could You please share visuaforce page anad class for above code
we have requirement with my client
and also Please suggent me how to put custom fields from contact object in the above code
Thanks
Question related to this:
Is it possible to have this .ics generated to the OOTB functionality that sends the meeting summary?
Also, here's the idea which should've been implemented many years ago already imho:
https://success.salesforce.com/ideaView?id=08730000000BqoQAAS
BR,
Olli H.