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

Error: Compile Error: Invalid identifier ' '. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'. at line 3 column 23
Hi,
I am getting bellow error.
Hi,
i am trying to send an email- Sending a Document as an Attachment, i am getting below error.
Anybody can help me on this , exactely where iam getting the error.
Thanks,
Chinnu
I am getting bellow error.
Hi,
i am trying to send an email- Sending a Document as an Attachment, i am getting below error.
Anybody can help me on this , exactely where iam getting the error.
Thanks,
Chinnu
public class SendingDocasattachmentExample { public pagereference sendDocAttach() { Document doc = [SELECT Id,Name FROM Document WHERE Name = 'attachment']; Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage(); semail.setDocumentAttachments(new ID[]{doc.id}); semail.setSubject('Sending Document as attachemnt example'); String[] sendTo = new String[]{'test.dm2@gmail.com'}; semail.setToAddresses(sendTo); semail.setPlainTextBody('Please find the attached document details'); Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail}); return null; } }
Greetings to you!
I don't see anything visibly wrong with the above code on line 3. You might be getting this error because of copy & paste issue. You can get characters that are not visible in the code, particularly when you copy/paste code.
Delete and re-type all the characters. Re-typing the code (not using copy/paste for anything) fixes the issue.
Also, setDocumentAttachments() is deprecated. You should use setEntityAttachments() instead. Please refer to below link for more information:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_outbound_single.htm
Try below code:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas