CRM Blog

E-mail Field - Open In Outlook or E-mail Activity

by Danny Varghese 03.04.09

Here's a simple JavaScript customization to enable an e-mail field, once filled in, have a user double-click it and open your default e-mail client with the address in the "To" field.

 

if(crmForm.FormType == 1 || crmForm.FormType == 2)

{

                crmForm.all.emailaddress1.ondblclick = function()

                {

                                var email = crmForm.all.emailaddress1.DataValue;

                                if ((email != null) && (email.length > 0))

                                {

                                     window.navigate("mailto:" + email);

                                }

                                                               

                }

}

 

Now if you want to make CRM open an e-mail activity instead of the default e-mail client, you can use the following code (when sending the email, CRM will use email address 1 regardless of what field was dobule clicked):

 

if(crmForm.FormType == 1 || crmForm.FormType == 2)

{

                crmForm.all.emailaddress1.ondblclick = function()

                {

                                var email = crmForm.all.emailaddress1.DataValue;

                                if ((email != null) && (email.length > 0))

                                {

                                     window.execScript(locAddActTo(4202))

                                }

                                                               

                }

}

Filed under:

Comments

# mukesh said on April 7, 2009 02:59 AM:

Hi Danny,

Can you help me with the code to set "cc" field on the email activity form to default to the user's system name(email address) on the "onLoad" event?

Once the "cc" field is defaulted to the user's email adddress, there should however be no limitation or restriction to prevent the user addiny many more recipients in the "cc" field.

your help will be appreciated

regards

# Danny Varghese said on April 8, 2009 02:45 PM:

Hi Mukesh,

If I understand you correctly, on the load of the form, you want to take the user's e-mail address and populate the "CC" field?  To do this with javascript, take a look at the following post:  www.crowehorwath.com/.../hide-show-fields-in-crm-4-0-based-on-security-role.aspx

The post has some javascript code to retrieve the userid of the current user.  You can modify this to retrieve the user's e-mail address.  Hope that helps!

Please let me know if you need anything else, thanks!

# Danny Varghese said on April 8, 2009 03:02 PM:

Another thing you can do is if you want to use BLOCKED SCRIPT

crmForm.all.cc.DataValue = crmForm.all.ownerid.DataValue;

That might be easier, good luck!

# Debbie said on April 16, 2009 03:46 PM:

I tried the first script, adding it to the form contact, on the email field properties under events...is this where i would place the script? I'm sorry but am new to CRM and scripting. Could i have more detailed instructions?

Thank you.

# Danny Varghese said on April 16, 2009 04:12 PM:

Hi Debbie,

You want to place this script in the onLoad() event of the form.  So you have to open the contact form in the customization section, click on Form properties, then events, then onLoad().  You can copy and paste the code there with the appropriate schema name of the field.  Save and publish and you shoul be good to go!

I hope this helps, good luck and please let me  know if I need to clarify further.

# Debbie said on April 16, 2009 04:51 PM:

Danny,

thanks so much for your quick response:). One more question, throught scripting can we set regarding and track in Crm?

Thanks again.

# Danny Varghese said on April 16, 2009 05:13 PM:

Hi Debbie,

Through CRM you can set the regarding.  For track in CRM, since it's a button, the only thing i can think of is to find the CRM function pressing the button calls.  Then maybe call that directly in your JavaScript.

Good luck!

# Ganni said on June 5, 2009 08:18 AM:

it is possible to defined the From addrese?

# Danny Varghese said on June 22, 2009 11:22 PM:

Hi Ganni,

With this current method there isn't because it will pull up an e-mail message with your default e-mail client.  You can change your default e-mail client to have a different "from" name.  

Another thing you can do is to create a .NET application and use SMTP to send an e-mail in which you can configure the "from" address.

Hope that helps!

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Security Check
Please answer the simple math problem below.

(required)