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

vba access

ResolvedVersion 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:

Autonumber in Excel

To create an autonumber field, can use the Offset() function.

In cell A1, enter the number 1.
Then in cell A2, enter this formula:

=OFFSET(A2,-1,0)+1

Then copy the formula from cell A2, down as far as you need.

See also: Autonumber in Excel forum post.

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.