0% found this document useful (0 votes)
23 views7 pages

Outlook

Uploaded by

Bob Farrell
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views7 pages

Outlook

Uploaded by

Bob Farrell
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

FROM CHATGPT

Sub SendEmail()

Dim OutlookApp As Object

Dim OutlookMail As Object

Dim Recipients As String

Dim Subject As String

Dim Body As String

Set OutlookApp = CreateObject("Outlook.Application")

Set OutlookMail = OutlookApp.CreateItem(0)

'Specify recipients, subject, and body of email

Recipients = "[email protected];[email protected];[email protected]"

Subject = "Subject line of email"

Body = "Body text of email"

With OutlookMail

.To = Recipients

.Subject = Subject

.Body = Body

.Send

End With

Set OutlookMail = Nothing

Set OutlookApp = Nothing


FROM CHATGPT MY VERSION

Sub SendEmail()

Dim OutlookApp As Object

Dim OutlookMail As Object

Dim Recipients As String

Dim Subject As String

Dim Body As String

Set OutlookApp = CreateObject("Outlook.Application")

Set OutlookMail = OutlookApp.CreateItem(0)

'Specify recipients, subject, and body of email

Recipients = "[email protected];[email protected]"

Subject = "Daily Dispatch"

Body = & date

With OutlookMail

.To = Recipients

.Subject = Subject

.Body = Body

.Display

‘.Send

End With

Set OutlookMail = Nothing

Set OutlookApp = Nothing


Sub SendWorkbookEmail() Dim OutApp As Object Dim OutMail As Object Dim Recipients As
String Dim Subject As String Dim Body As String Dim FilePath As String 'Get the email
recipients Recipients = "[email protected]; [email protected]; [email protected]"
'Set the email subject Subject = "Workbook Attachment" 'Set the email body Body =
"Please find attached the workbook." 'Get the file path of the active workbook
FilePath = ActiveWorkbook.FullName 'Create a new email message Set OutApp =
CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) 'Add the
recipients to the email message OutMail.To = Recipients 'Add the subject to the email
message OutMail.Subject = Subject 'Add the body to the email message OutMail.Body =
Body 'Add the workbook as an attachment to the email message OutMail.Attachments.Add
FilePath 'Send the email message OutMail.Send 'Release the email objects Set OutMail =
Nothing Set OutApp = Nothing End Sub

Sub SendWorkbookEmail()

Dim OutApp As Object

Dim OutMail As Object

Dim Recipients As String

Dim Subject As String

Dim Body As String

Dim FilePath As String

'Get the email recipients

Recipients = "[email protected]; [email protected]; [email protected]"

'Set the email subject

Subject = "Workbook Attachment"

'Set the email body

Body = "Please find attached the workbook."

'Get the file path of the active workbook

FilePath = ActiveWorkbook.FullName

'Create a new email message


Set OutApp = CreateObject("Outlook.Application")

Set OutMail = OutApp.CreateItem(0)

'Add the recipients to the email message

OutMail.To = Recipients

'Add the subject to the email message

OutMail.Subject = Subject

'Add the body to the email message

OutMail.Body = Body

'Add the workbook as an attachment to the email message

OutMail.Attachments.Add FilePath

'Send the email message

OutMail.Send

'Release the email objects

Set OutMail = Nothing

Set OutApp = Nothing

End Sub
+++

Sub Send_Email()

Dim OutApp As Object

Dim OutMail As Object

Dim Recipients As String

Dim Subject As String

Dim Body As String

Dim FilePath As String

'Get the email recipients

Recipients = "[email protected]; [email protected]"

'Set the email subject

Subject = "Workbook Attachment"

'Set the email body

Body = "Please find attached Daily Dispatch."

'Get the file path of the active workbook

FilePath = ActiveWorkbook.Daily Dispatch 2023.xlsm

'Create a new email message

Set OutApp = CreateObject("Outlook.Application")

Set OutMail = OutApp.CreateItem(0)

'Add the recipients to the email message

OutMail.To = Recipients
'Add the subject to the email message

OutMail.Subject = Subject

'Add the body to the email message

OutMail.Body = Body

'Add the workbook as an attachment to the email message

OutMail.Attachments.Add FilePath

'Send the email message

OutMail.Send

'Release the email objects

Set OutMail = Nothing

Set OutApp = Nothing

End Sub

+++

Sub AttachWorkbookIntoEmailMessage()

Dim OutlookApp As Object


Dim OutlookMail As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)

'Let us create the email message and display it


'Make sure to change the parameters below
With OutlookMail
.To = "[email protected]"
.Subject = "Have a look at this workbook"
.Body = "Hey John, Could you help out on this?"
.Attachments.Add ActiveWorkbook.FullName
.Display
End With

Set OutlookMail = Nothing


Set OutlookApp = Nothing

End Sub

You might also like