Custom Button in Outlook to send Emails to Salesforce
It often comes handy to have a button in Outlook, which allows you to automatically forward any email to Salesforce/e2a. To create this button, please follow steps below:
- STEP 1: Add the Macro to Outlook:
- Open Outlook and press 'alt' + 'F8' on your keyboard. This will open your Macro window.
- Enter 'Macro Name' and press 'Create'. This will open a new window. Please enter Macro Code Provided below. In 'emailAddress' enter the Email Service Address where you would like to forward your emails to. Save your code and close the window.
Dim emailAddress As String
Dim objMail As Outlook.MailItem
Dim strbody As String
Dim oldmsg As String
Dim senderaddress As String
Dim addresstype As Integer
' Set this variable as your helpdesk e-mail address
emailAddress = "EmailServiceAddress"
Set objItem = GetCurrentItem()
Set objMail = objItem.Forward
' Sender E=mail Address
senderaddress = objItem.SenderEmailAddress
'Searches for @ in the email address to determine if it is an exchange user
addresstype = InStr(senderaddress, "@")
' If the address is an Exchange DN use the Senders Name
If addresstype = 0 Then
senderaddress = objItem.SenderName
'adds the senders e-mail address as the created by object for the ticket and appends the message body
strbody = "#created by " & senderaddress & vbNewLine & vbNewLine & objItem.Body
objMail.To = emailAddress
objMail.Subject = objItem.Subject
objMail.Body = strbody
' remove the comment from below to display the message before sending
'Automatically Send the ticket
Set objItem = Nothing
Set objMail = Nothing
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Set GetCurrentItem = _
Set GetCurrentItem = _
- STEP 2: Add a Group on the main Ribbon for the button
- On main ribbon, right click and select 'Customize the Ribbon...'
- In the popup opened, three panels will be shown. In the right most panel:
- select the tab you want to add this button in
- Press 'New Group'
- Press 'Rename' to set appropriate name for your new button
- From middle panel, select 'Macro' in 'Choose commands from'
- Select your macro and add it to custom group you created above
- Following steps 2.2 and 2.3, rename your marco component too.
- Press Ok.
- The button you have added will be shown in ribbon. To forward any email, select the email and press this button.
Please contact us at firstname.lastname@example.org with any questions.
★★★★★ - EXCELLENT
★★★★☆ - GOOD
★★★☆☆ - OK
★★☆☆☆ - POOR
★☆☆☆☆ - RUBBISH