Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

vba macro

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » vba macro in outlook

vba macro in outlook

ResolvedVersion 2016

Ida has attended:
Introduction to Management course
Excel VBA Advanced course
Presentation Skills course

vba macro in outlook

object required in vba macro in outlook
copied the codes, but still the object is not being defined

RE: vba macro in outlook

Hi Ida,

Thank you for the forum question.

Late Binding:

The below code is if you do not activate the Outlook Object Library.


Sub sendemail()

Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

With OutMail
.To = "xxxx@xxxx.com"
.CC = ""
.BCC = ""
.Subject = " Monthly report for month " & Format(Date, "mmmm")
.Body = "Hello World!" & vbCrLf & "New line text"
.Attachments.Add "Enter the file path here"
.Display
'.Send
End With

Set OutMail = Nothing
Set OutApp = Nothing
End Sub


Sub sendemail()

Early Binding:

The below code is if you activate the Outlook Object Library

Sub sendemail()

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "xxxx@xxxx.com"
.CC = ""
.BCC = ""
.Subject = " Monthly report for month " & Format(Date, "mmmm")
.Body = "Hello World!" & vbCrLf & "New line text"
.Attachments.Add "Enter the file path here"
.Display
'.Send
End With

Set OutMail = Nothing
Set OutApp = Nothing
End Sub



I hope this makes sense.

Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Wed 29 Aug 2018: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Get back to active cell

If you have scrolled away from the active celland want to get back t it quicly you can Ctrl and Backspace to get back

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.