• Marx Prathap Singh Shanmugam
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Here is my code
Contact cts= new Contact();
cts.Id=[SELECT Id FROM Contact Where Email='contact@email.com'].Id;
System.debug('Contact id'+cts.Id);
EmailMessage emailMsg = new EmailMessage(); // Created a EmailMessage and copy all details from above.
emailMsg.FromAddress='fromaddress@email.com';
emailMsg.ToAddress='toaddress@email.com';
emailMsg.Subject='Email using Apex';
emailMsg.RelatedToId=cts.Id;
emailMsg.HtmlBody='Temp Email using apex code';
emailMsg.ParentId = null; //Attach with the case
emailMsg.MessageDate = system.now();
emailMsg.Status = '0';
insert emailMsg;
Here is my code
Contact cts= new Contact();
cts.Id=[SELECT Id FROM Contact Where Email='contact@email.com'].Id;
System.debug('Contact id'+cts.Id);
EmailMessage emailMsg = new EmailMessage(); // Created a EmailMessage and copy all details from above.
emailMsg.FromAddress='fromaddress@email.com';
emailMsg.ToAddress='toaddress@email.com';
emailMsg.Subject='Email using Apex';
emailMsg.RelatedToId=cts.Id;
emailMsg.HtmlBody='Temp Email using apex code';
emailMsg.ParentId = null; //Attach with the case
emailMsg.MessageDate = system.now();
emailMsg.Status = '0';
insert emailMsg;