adding .Body to email link

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,227
Office Version
  1. 2010
Platform
  1. Windows
Hi, please can you help i have the code below where i have a button and when i click on it it goes to email, but i want to add .Body into the code please can you advise how i add this into the code please?

Code:
Sub Button3_Click()
    Link = "mailto:john.dowe@talk.com; john.dowe@talk.com?cc=john.dowe@talk.com; john.dowe@talk.com; john.dowe@talk.com; john.dowe@talk.com; john.dowe@talk.com&subject=Handover on day"
    On Error GoTo NoCanDo
    ActiveWorkbook.FollowHyperlink Address:=Link, NewWindow:=True


    Exit Sub
NoCanDo:
    MsgBox "Cannot open " & Link
End Sub
 
Last edited:

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
hi i have treid an update with the body code below but it doesn't work unfortuantely, hope you can help? :)
Code:
Sub Button3_Click()
Dim xMailBody As String
    Link = "mailto:Donald.Mackenzie@eonenergy.com; jayne.weston@eonenergy.com?cc=derek.mcateer@eonenergy.com; retuk-new-connections-planning@eonenergy.com; david.price3@eonenergy.com; alan.mclauchlan@eonenergy.com; neil.burrows@eonenergy.com&subject=Handover on day"
    On Error GoTo NoCanDo
    ActiveWorkbook.FollowHyperlink Address:=Link, NewWindow:=True
    Exit Sub
    xMailBody = "Hi" & vbNewLine & vbNewLine & _
              "Please see below" & vbNewLine & _
              "Many Thanks"
                  On Error Resume Next
 Exit Sub
NoCanDo:
    MsgBox "Cannot open " & Link
End Sub
 
Upvote 0
well you need to call outmail and creatobject("outlook.application")

Try this -- and modify as per your need.
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
With Application
.EnableEvents = False
.ScreenUpdating = False
End With


With OutMail
.To = sTo
.cc = sCC
.Subject = ssubject
.body = sBody
.Send
 
Upvote 0
hi, thanks for the response back will this work as a link for the button?
 
Upvote 0
yes it will, you can add the code to the click of the button as well.
 
Last edited:
Upvote 0
Hi i tried enterging and ameding the code like below but the email addresses come up red color and error can you advise please
Code:
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
With Application
.EnableEvents = False
.ScreenUpdating = False
End With


With OutMail
.To = Don.Mac@talktalk.com; Don.Mack@talktalk.com
.cc = erik.mc@talktalk.com
.Subject = Handover on day
.body = hello
.Send
 
Upvote 0
try this.

Dim OutApp As Object
Dim OutMail As Object
Dim sTo As String, sCC As String, sSbject As String, sBody As String
Set OutApp = CreateObject("Outlook.Application")
With Application
.EnableEvents = False
.ScreenUpdating = False
End With




Set OutMail = OutApp.CreateItem(0)
With OutMail
.sTo = "Don.Mac@talktalk.com; Don.Mack@talktalk.com"
.sCC = "erik.mc@talktalk.com"
.sSubject = "Handover on day"
.body = "hello"
.Send
 
Upvote 0
hi i get a run time error on the .sTo saying 'Run-Time error 438, object doesn't support this property or method
 
Upvote 0
try this.

Private Sub CommandButton1_Click() -- change as per your need.
Dim OutApp As Object
Dim OutMail As Object
Dim sTo As String, sCC As String, sSbject As String, sBody As String
Set OutApp = CreateObject("Outlook.Application")
With Application
.EnableEvents = False
.ScreenUpdating = False
End With


ssubject = "Handover on day"
sTo = "Don.Mac@talktalk.com; Don.Mack@talktalk.com"
sCC = "erik.mc@talktalk.com"
sBody = "Hello"


Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = sTo
.CC = sCC
.Subject = ssubject
.body = sBody
.Send
End With
End Sub
 
Upvote 0
That works great thank you :) on the body please can you advise how i can add new lines and put in breaks please?
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,181
Members
448,871
Latest member
hengshankouniuniu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top