0

I want to send email to a fixed user's email address let say ([email protected] (mailto:[email protected])) when events due date over and description is not filled. I wrote batch but it send to email event owner not specific user. could you please help me to find out how can I put hard coated email address in batch. below is my batch please have a look and let me know if any changes are required.

3

1 Answer 1

1

When you are sending an e-mail from apex code.. make sure you explicitly set the toEmailAddress... such as

List<Messaging.SingleEmailMessage> msgs = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();

// KEY LINE:
msg.setToAddress('[email protected]');

// Set other message details
// eg. msg.setTemplateID(template.Id); 
// eg. msg.setWhatId(custom_object.Id);

msgs.add(msg);
Messaging.sendEmail(msgs,false);

That will explicitly send the e-mail to the given hard coded address.

I believe other advise has included using a custom setting or custom label to store a contextual email address in a declarative feature, so you don't have to alter apex to change this e-mail address if it ever moves.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .