UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Attaching A User Selected File For Outlook, Access 2003    
 
   
graeme_706
post Dec 23 2017, 06:13 PM
Post#1



Posts: 69
Joined: 3-August 10
From: Scotland, UK


Hi,

I have some VBA code within an button (Label58) which takes details from combo boxes (such as email Recipient, Subject, Body and attachment) and creates an email within Outlook 2003. It works perfectly well but I have to go into VBA in order to type in the attachment file name such as C:\MyPDF\Invoice.pdf.

The code below works fine. What I want to be able to do is allow the user to browse the computer and select which file to attach, rather than have it "pre-programmed". If this is not possible, could the user type into a cell in a text box or combo box or whatever the file location & name ?

Here's the code which works with the pre-programmed attachment


Private Sub Label58_Click()
Dim bcRet As Boolean
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Dim objAttach As Outlook.Attachments
Set olApp = Outlook.Application
Set objMail = olApp.CreateItem(olMailItem)
objMail.To = Combo7.Column(1)
‘ Combo7.Column(1) returns the recipient’s email address
objMail.Subject = Combo64.Value
‘ Combo64.value returns the Subject line content
objMail.Body = "Hi " & Combo7.Column(2) & "," & Chr$(13) & Chr$(13) & Combo70.Value & Chr$(13) & Chr$(13) & "Thanks," & Chr$(13) & Chr$(13) & "Graeme"
Set objAttach = objMail.Attachments
objAttach.Add "C:\MyPDF\Invoice.pdf"
objMail.Display
End Sub



Thanks in advance !!



I'm using Access 2003, Windows 10, Microsoft Outlook 2003
Go to the top of the page
 
MadPiet
post Dec 23 2017, 06:34 PM
Post#2



Posts: 2,426
Joined: 27-February 09



You need to call the Windows Open/Save File dialog
Go to the top of the page
 
graeme_706
post Dec 24 2017, 08:34 AM
Post#3



Posts: 69
Joined: 3-August 10
From: Scotland, UK


Thanks MadPiet,

I'm a bit lost with the dialog box details on your link, looks a bit complex.

Any way of doing what I'm after by having the user enter the drive path by typing it in somewhere ?

Graeme
Go to the top of the page
 
MadPiet
post Dec 24 2017, 12:31 PM
Post#4



Posts: 2,426
Joined: 27-February 09



bummer! I can't really test it, since that's a 32-bit call and I have a 64-bit operating system... hopefully someone with a 32-bit OS and 32-bit version of Access can test it for you. But I have used that code before... takes a bit to get your head around, and then it's not so bad. In a nutshell, you declare a string to hold the full file path, and then you attach that... with

appOutlook.Message.Attachments.Add(strFile)

if I remember correctly. Haven't done it in a long long time.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    19th July 2018 - 06:17 PM