I am sending mail from excel through lotus notes
in column "J" email address is there
in column "Q" Subject is there
in column "S" body of text
I want to add name of the person before column "S" ie:- in column "R" and then body will continue
and if possible attachment path can be given in one column so that the attachment can sent pdf or xlsx
in column "J" email address is there
in column "Q" Subject is there
in column "S" body of text
I want to add name of the person before column "S" ie:- in column "R" and then body will continue
and if possible attachment path can be given in one column so that the attachment can sent pdf or xlsx
Code:
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub SendEMail1(r As Long)
Dim Email As String, Subj As String
Dim Msg As String, URL As String
'Get the email address
Email = Cells(r, 10) & ";" & Cells(r, 11) 'column J;column K
'Message subject
Subj = Cells(r, 17) 'column Q
'Compose the message
Msg = Cells(r, 19) & "," & vbCrLf & vbCrLf 'column S
'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:02"))
Application.SendKeys "%1"
End Sub