Is It possible to Send and Receive Email from Account,Lead,Opportunity,Quotes,Case in communities..
I am looking for a working solution for email component in lightning communities.
I need a custom lightning component , which can send the emails from salesforce to any email address.
Once email is send , that information should be saved on that particular salesforce record .
If reply is received by salesforce , that information also i have to maintain in that particular record. I should able to reply to the same email from salesforce.
I checked with inbound and out bound email messages, but I am unable to capture group of conversations and i can't reply for the received email.
Tried to do with email services,But I cannot find the options to reply to particular email as like above screen shot which is in activity History.Below screen shot is for Email Message which is Recieved using email service,
Code Used for Email Service to store inbound Messages,above screenshot is for the messages received from my personal email
global class TXP_EmailServiceInbound implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
String myPlainText= '';
// Add the email plain text into the local variable
myPlainText = email.plainTextBody;
string sss= email.subject;
string [] a = sss.split('\\(');
system.debug('a0 ='+ a[0]);
system.debug('a1 ='+ a[1]);
string [] bb = a[1].split('\\)');
system.debug('bb '+bb[0] );
string subrecid = bb[0] ;
List<List<sObject>> searchList = [FIND :subrecid IN ALL FIELDS
RETURNING Account(id),Contact(id),Lead(id)];
Account[] searchAccounts = (Account[])searchList[0];
Contact[] searchContacts = (Contact[])searchList[1];
Lead[] searchLeads = (Lead[]) searchList[2];
If (subrecid.startsWith('003')){
Contact vConid = [SELECT Id, Name, Email
FROM Contact
WHERE id = :subrecid
LIMIT 1 ];
system.debug('bb2345id '+ vConid );
//Add Inbound Email Message for contact
EmailMessage caseEmailMessage = new EmailMessage();
caseEmailMessage.ToAddress = String.join(email.toAddresses, ',');
//caseEmailMessage.CcAddress = String.join(email.ccAddresses, ',');
caseEmailMessage.FromAddress = email.FromAddress;
caseEmailMessage.FromName = email.FromName;
caseEmailMessage.Subject = email.subject;
caseEmailMessage.status = '3';
caseEmailMessage.HtmlBody = email.htmlBody;
System.debug('htmlBody:>>>> ' + email.htmlBody );
caseEmailMessage.Incoming= True;
caseEmailMessage.TextBody = email.plainTextBody;
System.debug('TextBody:>>>>> ' + email.plainTextBody);
caseEmailMessage.Contact__c = vConid.Id;
vConid.EmailMessageId__c = email.messageId;
update vConid;
insert caseEmailMessage;
System.debug('Reply Email: ' + caseEmailMessage );
// Add Email Message Relation for id of the sender
EmailMessageRelation emr = new EmailMessageRelation();
emr.EmailMessageId = caseEmailMessage.id;
emr.RelationId = UserInfo.getUserId(); // user id of the sender
emr.RelationAddress = UserInfo.getUserEmail();
emr.RelationType = 'FromAddress';
insert emr;
system.debug('>>>>>=='+ emr );
}
else{
}
}
} In simple words similiar like Email To case Feature ,not about creating records,but its about maintain the email loop one to one with same record/Case...
Please share your Inputs!!!..Please Let know if you need more info...
Reply Error:
I need to Reply to Email Meassage which I have Received for Particular Lead or Contact.Error comes up You cannot Perform this Action.How to customize the Reply and ReplyAll to attach custom Lightning Component Page.
I can see Delete Button Available for sent Emails,
Delete Button Not Available for Received Email,