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
676 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
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…

920 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

15 Experts available now in Live!

Get 1:1 Help Now