Email Service Inbound
EmailServiceInbound
created email service:
created email service:
=> Email Service Name test
========================EmailServiceInbound=================================================================================
/** Class Name : EmailServiceInbound
* Description : For all incoming email messages , this class invoke.
* Created By : Naveen Goud
**/
global class 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;
system.debug('####unique message ID##'+email.messageId);
// For storing Relation Id
string oppcid ='';
string sss= email.subject;
EmailMessage conEmailMessage = new EmailMessage();
conEmailMessage.ToAddress = String.join(email.toAddresses, ',');
conEmailMessage.FromAddress = email.FromAddress;
conEmailMessage.FromName = email.FromName;
conEmailMessage.Subject = email.subject;
conEmailMessage.status = '2';
conEmailMessage.HtmlBody = email.htmlBody;
System.debug('htmlBody:>>>> ' + email.htmlBody );
conEmailMessage.Incoming= True;
conEmailMessage.TextBody = email.plainTextBody;
System.debug('TextBody:>>>>> ' + email.plainTextBody);
insert conEmailMessage;
System.debug('Reply Email: ' + conEmailMessage );
// Add Email Message Relation for id of the sender
EmailMessageRelation emr = new EmailMessageRelation();
emr.EmailMessageId = conEmailMessage.id;
emr.RelationAddress = email.FromAddress;
emr.RelationType = 'FromAddress';
insert emr;
system.debug('>>>>>=='+ emr );
return result ;
}
}
============================================================================================================================================================
created Vf page:
========================TM_EmailChangeProfile=====================================================================================================
By: Naveen Kumar Goud
By: Naveen Kumar Goud
Thanks Naveen for your contribution to this blog.
ReplyDeleteThe writer has outdone himself this time. It is not at all enough; the website is also utmost perfect. I will never forget to visit your site again and again. one funnel away challenge
ReplyDelete