98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » VBA - Access
VBA - Access
Resolved · 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 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
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 formulaBefore you type the equal sign, type an apostrophe: ' |