Hi,
I'm using Infopath for the first time and cant seem to figure out how to handle file attachments on my form. I am using an access database as my data source but on my form, which is a project request form, and I'd like to have a section where the user can upload whatever attachments may be be needed to complete the request. So I created a new field and change the file type to attachment in the data source. However, data connections to a database do not allow me to submit this field. So I decided to create a second data connection that would submit it to my email instead. But this isnt working either. So then I used some VBscript to do this but it errors out at the attachments.add line. Is my data source field referenced correctly? If not can somebody give me a heads up on what wrong with it. Also if anyone has any ideas on how to solve this any other way, that would be great. Thanks!
Sub CTRL60_4_OnClick(eventObj)
Dim objOutlook
Dim objOutlookMsg
Dim objOutlookRecip
Dim objOutlookAttach
Dim frmSavePath 'Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application") Set objOutlookMsg = objOutlook.CreateItem(0) 'olMailItem
With objOutlookMsg 'Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("my email")
objOutlookRecip.Type = 1 'olTo
.Subject = "This is an Automation test with Microsoft Outlook"
.body = "This is the body of the message"
.Importance = 2 'High importance
'Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
Set objOutlookAttach = .Attachments.Add(XDocument.DOM.selectSingleNode("/my:myFields/my:Attachments"))
Display the message before sending
.display
End With
Set objOutlook = Nothing
Set objOutlookMsg = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
End Sub