Hi,
I am in need of sending a personalised email to a large number of personnel.
This email needs to have a word document attached that can be updated and returned to me.
So far I have the code which is working that sends the emails. I just can't seem to find how to attached a file.
I am very new to VBA.
Any help would be very much appreciated!
I am in need of sending a personalised email to a large number of personnel.
This email needs to have a word document attached that can be updated and returned to me.
So far I have the code which is working that sends the emails. I just can't seem to find how to attached a file.
Code:
Sub SendEMail()
Dim Email As String, Subj As String
Dim Msg As String, URL As String
Dim r As Integer, x As Double
For r = 2 To 2 'data in rows 2-2
' Get the email address
Email = Cells(r, 3)
' Message subject
Subj = "Profile Update"
' Compose the message
Msg = Msg & "Dear " & Cells(r, 1) & "," & vbCrLf & vbCrLf
Msg = Msg & "As we are fast approaching the end of the year, we are going through an admin excerise to ensure we have the most up to date information on our system." & vbCrLf & vbCrLf
Msg = Msg & "If you haven't already, please complete the attached form and return to me as soon as possible" & vbCrLf
Msg = Msg & "Any questions, please feel free to contact me" & vbCrLf
Msg = Msg & "Many Thanks" & vbCrLf & vbCrLf
Msg = Msg & "Name" & vbCrLf
Msg = Msg & "Position" & vbCrLf
' Replace spaces with %20 (hex)
Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")
Msg = Application.WorksheetFunction.Substitute(Msg, " ", "%20")
' Replace carriage returns with %0D%0A (hex)
Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%0D%0A")
' Create the URL
URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg
' Execute the URL (start the email client)
ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus
' Wait two seconds before sending keystrokes
Application.Wait (Now + TimeValue("0:00:01"))
Application.SendKeys "%s"
Next r
End Sub
I am very new to VBA.
Any help would be very much appreciated!