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

Please fit the below message in HTMLbody
HI Everyone
I wanted to display my message in following format can amyone help me out
this is what am trying to do, i dont want to use email templates,please helpme out to fix it.here am attaching(in sample code) how my message wants to loooks like
Am trying the above shown messsage in the following format it doesnt works as the above message:--
message.setSubject('Session is NOT Created!');
String body = 'Attention:';
body += 'A session is created for the following Account and opportunity';
body += 'Account: {!Account.Name}';
body += 'Contact: {!opportunity.Name}';
message.setHtmlBody(body);
Thanks in Advance
I wanted to display my message in following format can amyone help me out
this is what am trying to do, i dont want to use email templates,please helpme out to fix it.here am attaching(in sample code) how my message wants to loooks like
Subject : Session is NOT Created Attention: A session is created for the following Account and opportunity Account: {!Account.Name} Contact: {!opportunity.Name} Thank you
Am trying the above shown messsage in the following format it doesnt works as the above message:--
message.setSubject('Session is NOT Created!');
String body = 'Attention:';
body += 'A session is created for the following Account and opportunity';
body += 'Account: {!Account.Name}';
body += 'Contact: {!opportunity.Name}';
message.setHtmlBody(body);
Thanks in Advance
ToAddresses = new List<string>();
toaddresses.add('nachu.srm@gmail.com');
subject = 'Session is NOT Created'
Body = '<html><head>Attention : </head><body><br/> A session is created for the following Account and opportunity <br/> Account:'+{!Account.Name} +'<br/> Contact:'+ {!opportunity.Name} + '<br/>Thank You </body></html>';
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setSubject( subject );
email.setToAddresses(ToAddresses);
email.setHTMLBody( body );
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
Thanks,
Nachiapphan RY
All Answers
ToAddresses = new List<string>();
toaddresses.add('nachu.srm@gmail.com');
subject = 'Session is NOT Created'
Body = '<html><head>Attention : </head><body><br/> A session is created for the following Account and opportunity <br/> Account:'+{!Account.Name} +'<br/> Contact:'+ {!opportunity.Name} + '<br/>Thank You </body></html>';
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setSubject( subject );
email.setToAddresses(ToAddresses);
email.setHTMLBody( body );
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
Thanks,
Nachiapphan RY
Thanks for the quick reply,am getting the following error,can you please have a look in to it
Error: Compile Error: unexpected token: '{' (this error is when am copy pasting as the above the code)
Error: Compile Error: line breaks not allowed in string literals at line(this is when am spliting the code) as below,please check it once,thanks again
subject = 'Session is NOT Created!'
Body = '<html> <head>Attention : </head><body><br/> A session is created for the following Account and opportunity <br/> Account:'+{!Account.Name} +'<br/> opportunity:'+ {!opportunity.Name} + ' <br/> Thank You </body> </html>';
Am seeing the following error on the below line.Please have a look
Error: Compile Error: unexpected token: '{'
Thanks again