vba access

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

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » VBA - Access

VBA - Access

resolvedResolved · High Priority · Version 2007

Grace has attended:
Excel VBA Intro Intermediate course

VBA - Access

Hi there,

How do I send an email through VBA in Access please?

Also rather than doing multiple Dlookup's (which slows Access down) is there anything else in VBA I can do?

Thanks,
Grace

RE: VBA - Access

Hi Grace,

Thank you for your question and welcome to the forum.

Here is some code for the outlook email that should help you. You will need to go to tools and references and tick the checkbox for the Outlook library.

Dim olApp As Object
Dim objMail As Object

On Error Resume Next 'Keep going if there is an error


Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open


If Err Then 'Outlook is not open
Set olApp = CreateObject("Outlook.Application") 'Create a new instance of Outlook
End If

'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)

With objMail

'Set body format to HTML
.BodyFormat = olFormatHTML
.To = "Your Mail"
.Subject = "Subject"
.HTMLBody = "Text"
.send

End With

MsgBox "Operation completed successfully"


I hope this helps. The other question needs some more looking into.

Regards

Simon

Thu 23 May 2013: 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:

Using an equal (=) sign that isn't part of a formula

Before you type the equal sign, type an apostrophe: '
Then type your equal sign: = (and anything else you want to add after your equal sign)
Press ENTER.

(the apostraphe will disappear

View all Excel hints and tips


Server loaded in 0.07 secs.