3

On a Site.com page we've created there is a 'Contact Us' form that when filled out and submitted, it creates an item in a 'ContactUS' object inside Salesforce. The 'ContactUS' object contains general information like name, email address, a specific message, etc.

We want an email alert to be sent out to our support team with the contents of the 'ContactUS' object.

I have it set up the email alert, and it works as needed, however, the 'From Email Address' shows something like no-reply@salesforce.com on behalf of mysite guest user [main_dev@softco.com] (As it looks from within my Outlook).

How can I get the email alert to put the user's email address from the 'ContactUS' field? The only option I have in the 'Edit Email Alert' for 'From Email Address' is 'Current User's email address'.

enter image description here

4

I don't believe you'll be able to use a custom field as your from address for e-mail alerts. You can't even use the standard e-mail field on a contact as the from address for an alert. However, you can create a trigger to send e-mails when a new contact us record is created. The documentation for sending e-mails via Apex Code is here: Outbound Email docs

Here's an example trigger:

trigger ContactUsEmail on ContactUS ( after insert )
{
    List<Messaging.Email> messages = new List<Messaging.Email>();
    for ( ContactUS contactUsRecord : trigger.new )
    {
        // Create the e-mail object and set options.
        Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
        // If you set a target object Id rather than setting an e-mail address then
        // the e-mail won't count towards your daily e-mail limit.
        // If you want to use a template with merge fields from the contactus object
        // then you have to set a target object ID here.  If you want to notify
        // multiple users then you'll need to use a MassEmailMessage object to set
        // multiple target object Ids
        message.setTargetObjectId( '<contact, lead or user id>' );
        message.setWhatId( contactUsRecord.Id );
        message.setReplyTo( '<contact us e-mail address>' );
        message.setSenderDisplayName( '<contact us name or other name>' );
        message.setSubject( 'Contact us form subject' );
        // Either use a plain text body (and optionally HTML body) or set a template ID
        // using setTemplateId() to use an e-mail template
        message.setPlainTextBody( 'Simple message body.' );
        // Add it to our list of messages to send.
        messages.add( message );
    }
    // Send all the e-mails.
    Messaging.SendEmailResult[] results = Messaging.sendEmail( messages );
}

Another suggestion would be to use e-mail alerts but instead of having the e-mail come from the person who filled out the contact us form, add a mailto: link in the message that the responder can click on that will open a new e-mail window with the e-mail address and subject pre-populated. For example: <a href="mailto:user@company.com?Subject=Subject here&Body=Body text here.">Respond to this contact request</a>.

| improve this answer | |
3

You can add whatever email addresses that you want by just verifying them under "Setup -> Email Administration -> Organization-Wide Addresses -> Add". Then once it's verified, it will show up as an option in the "From Email Address" field.

| improve this answer | |
  • In this particular case I want to use the custom field 'email' within the ContactUS object. Which doesn't seem like something I can do. @E.J. Wilburn posted an answer that best describes a solution. Thank you for your input though. – Emmanuel F. Aug 1 '12 at 14:43
0

I'm going to say you can't unless you replace the alert with a trigger that sends the email.

Sadly dynamically adjusting from and to addresses in email alert/workflow rules has limited functionality.

| improve this answer | |
0

We have setup an organization wide email address (in your case it will be something like 'Contact Us Repair Notifications') and updated the email alerts to use this From address. You cannot use a custom field to drive the From address on the email alerts (atleast not until now).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.