Created
July 1, 2020 22:10
-
-
Save salesforceBen/84169b4ed9ae34c994f0c011d0f22122 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DragAndDropController | |
{ | |
public String bccAddresses {get; set;} | |
public String ccAddresses {get; set;} | |
public String toAddresses {get; set;} | |
public String caseId {get; set;} | |
public String caseIdChosen {get; set;} | |
public String contactIdToEmail {get; set;} | |
public String externalComments {get; set;} | |
public String htmlBody {get; set;} | |
public String subject {get; set;} | |
public String textBody {get; set;} | |
public DragAndDropController(ApexPages.StandardController controller) | |
{ | |
controller.addFields(new List<String>{‘Id’}); | |
caseIdChosen = controller.getId(); | |
List<EmailMessage> emailMessages = [SELECT Id, bccAddress, ccAddress, htmlBody, subject, textBody, toAddress FROM EmailMessage WHERE Parent.Id =: caseIdChosen ORDER BY CreatedDate ASC LIMIT 1]; | |
for (EmailMessage em : emailMessages) | |
{ | |
bccAddresses = em.BccAddress; | |
ccAddresses = em.ccAddress; | |
htmlBody = em.HtmlBody; | |
subject = em.Subject; | |
textBody = em.TextBody; | |
toAddresses = em.ToAddress; | |
} | |
for (Contact contactsToAnalyse : [SELECT Id FROM Contact WHERE Email =: toAddresses LIMIT 1]) | |
{ | |
contactIdToEmail = contactsToAnalyse.Id; | |
} | |
} | |
public String goToEmailDragAndDrop() | |
{ | |
String emailAuthorUI = URL.getSalesforceBaseUrl().toExternalForm() + ‘/_ui/core/email/author/EmailAuthor?p24=’ + toAddresses + ‘&p3_lkid=’ + caseIdChosen + ‘&p23=’ + textBody + ‘&p2_lkid=’ + contactIdToEmail + ‘&p4=’ + ccAddresses + ‘&p5=’ + bccAddresses + ‘&p6=’ + subject; | |
return emailAuthorUI; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment