Option Explicit
Const MailTo As String = "[EMAIL="Toto@xld.com"]Toto@xld.com[/EMAIL]"
Const MailCC As String = "[EMAIL="Zaza@xld.com"]Zaza@xld.com[/EMAIL]; [EMAIL="Titi@xld.com"]Titi@xld.com[/EMAIL]"
[COLOR=darkgreen][B]'================================================= ================[/B][/COLOR]
[B][COLOR=darkgreen]'Need reference to Microsoft Outlook xx Objects Library[/COLOR][/B]
[B][COLOR=darkgreen]'[/COLOR][/B]
[B][COLOR=darkgreen]'C:\Program Files\Microsoft Office\OfficeXX\msoutl.olb[/COLOR][/B]
[B][COLOR=darkgreen]'================================================= ================[/COLOR][/B]
Sub SendingDailyMail()
Dim OLApplication As Outlook.Application, OLMail As Outlook.MailItem
Dim Message As String
Dim TheDay As Date
TheDay = Date
Message = "Good Morning," & vbCrLf & vbCrLf & _
"= = = This is an automatic generated email = = =" & vbCrLf & vbCrLf & _
" Please find enclosed the Report for Transactions for : " & Format(TheDay, "DDDD") & _
" " & Format(TheDay, "DD/MM/YYYY") & vbCrLf & _
"Best Regards" & vbCrLf & "@+Thierry" & vbCrLf & vbCrLf
Set OLApplication = CreateObject("Outlook.Application")
Set OLMail = OLApplication.CreateItem(OLMailItem)
With OLMail
.To = MailTo
.CC = MailCC
.Importance = olImportanceNormal
.Subject = "Daily Transactions Summary Reports (" & _
Format(TheDay, "YYYY-MM-DD") & ")"
.Body = Message
.Attachments.Add "[B]I:\MC_PROD\Reports\Daily\Test1.xls[/B]" '[B][COLOR=darkgreen]<= Can be a String Variable[/COLOR][/B]
.Attachments.Add "[B]I:\MC_PROD\Reports\Daily\Test1.pdf[/B]"
.Categories = "Daily"
.OriginatorDeliveryReportRequested = True
.ReadReceiptRequested = True
.Send '<<<<<<<<<<<<<<<TO SEND DIRECTLY
.Display '<<<<<<<<<<<<<TO SEE THE MAIL FIRST
End With
Set OLApplication = Nothing
Set OLMail = Nothing
End Sub