Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 700
  • Last Modified:

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

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
Lou Dufresne
Asked:
Lou Dufresne
2 Solutions
 
Mikal613Commented:
0
 
Benjamin_LukCommented:
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
 
Lou DufresneIT Business Analyst CSM / Project ManagerAuthor Commented:
Thanks you for your assistance.

Lou
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now