Solved

Need a method to email a MDB file by way of MS Outlook, not Outlook Express from within MS Access

Posted on 2003-10-29
3
675 Views
Last Modified: 2012-06-27
I received the following code from an EE member but it does not work with Outlook
Any ideas on how to modify it.

I pass to the function the parameters using a macro with the following function
   
RunCode
FunctionName      EmailFile ("Loudufresne@qwest.net",F:\Qwest\CopeXdock.mdb")


This is the code that does not work with Outlook.

Public Function EmailFile(ByVal strEmailAddress As String, ByVal strAttachmentLocation As String)
    Dim appOutlook As Object
    Dim emailItem As Object
    Dim emailAttachments As Object
    Dim emailAttach As Object
   
    Set appOutlook = CreateObject("OutlookExpress.Application")
    Set emailItem = appOutlook.CreateItem(0)
    Set emailAttachments = emailItem.Attachments
    Set emailAttach = emailAttachments.Add(strAttachmentLocation, 1)
   
    emailItem.Recipients.Add (strEmailAddress)
    emailItem.Subject = "Daily XDock Report (" & Format(Now(), "YYYYMMDD") & ")"
    emailItem.Body = "Please find attached, Access Database containing today's Xdock data , Thank You." & vbCrLf
    emailItem.Send
   
    Set emailAttach = Nothing
    Set emailAttachments = Nothing
    Set emailItem = Nothing
    Set appOutlook = Nothing
End Function


0
Comment
Question by:Lou Dufresne
3 Comments
 
LVL 48

Assisted Solution

by:Mikal613
Mikal613 earned 50 total points
ID: 9647169
0
 
LVL 8

Accepted Solution

by:
Benjamin_Luk earned 350 total points
ID: 9647385
In your function code change:
Set appOutlook = CreateObject("OutlookExpress.Application")
To:
Set appOutlook = CreateObject("Outlook.Application")

And set you calling parameters correct:

("Loudufresne@qwest.net",F:\Qwest\CopeXdock.mdb")

Should be:
("Loudufresne@qwest.net","F:\Qwest\CopeXdock.mdb")

Regards

Ben
0
 
LVL 1

Author Comment

by:Lou Dufresne
ID: 9647789
Thanks you for your assistance.

Lou
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now