Hi,
I am a beginner when it comes to VBA, I have my spread sheet and I am in Developer trying to add a code for CreateMail.
As of now I have this Function (taken from a different spread sheet):
Function Mail_PDF_Outlook(FileNamePDF As String, StrTo As String, _
StrSubject As String, StrBody As String, Send As Boolean)
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = StrTo
.CC = ""
.BCC = ""
.Subject = StrSubject
.Body = StrBody
.Attachments.Add FileNamePDF
If Send = True Then
.Send
Else
.Display
End If
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Function
And to this Function I have this "Sub":
Sub Mail()
Dim StrTo As String
Dim StrSubject As String
Dim StrBody As String
StrTo = Sheets("GlobalPara").Cells(19, 5)
StrSubject = Sheets("GlobalPara").Cells(20, 5)
StrBody = Sheets("GlobalPara").Cells(21, 5)
Mail , StrTo, StrSubject, StrBody, False
End Sub
Can anyone help me getting the correct Function without PDF attachement and the correct Sub?
thank you.
I am a beginner when it comes to VBA, I have my spread sheet and I am in Developer trying to add a code for CreateMail.
As of now I have this Function (taken from a different spread sheet):
Function Mail_PDF_Outlook(FileNamePDF As String, StrTo As String, _
StrSubject As String, StrBody As String, Send As Boolean)
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = StrTo
.CC = ""
.BCC = ""
.Subject = StrSubject
.Body = StrBody
.Attachments.Add FileNamePDF
If Send = True Then
.Send
Else
.Display
End If
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Function
And to this Function I have this "Sub":
Sub Mail()
Dim StrTo As String
Dim StrSubject As String
Dim StrBody As String
StrTo = Sheets("GlobalPara").Cells(19, 5)
StrSubject = Sheets("GlobalPara").Cells(20, 5)
StrBody = Sheets("GlobalPara").Cells(21, 5)
Mail , StrTo, StrSubject, StrBody, False
End Sub
Can anyone help me getting the correct Function without PDF attachement and the correct Sub?
thank you.