Sam Summers
Registered User.
- Local time
- Today, 23:59
- Joined
- Sep 17, 2001
- Messages
- 939
Hi there,
I am trying to email a persons pdf file by clicking on a button from their details form.
I am close but all i am getting is a blank email without the attachment inserted. I have left the other attempts commented out. When i run any of them i am getting an error saying "cannot find file"
Any ideas?
Thanks in advance
Here is the code i am using:
Private Sub EmailBtn_Click()
Dim sFileName As String
Me.MailFile (sFileName)
End Sub
********************************************
Public Function MailFile(sFileName As String)
On Error GoTo Err_MailFile
Dim I As String
Dim S As String
'I = Me.First_Name.Value
'S = Me.Surname.Value
sFileName = "F:\Personnel Certs\Rope Access\" & I & S & "\" & I & S & ".pdf"
Dim appOutl As Object
Dim MyNameSpace As Object
Dim myemail As Object
On Error GoTo Err_MailFile
Set appOutl = CreateObject("Outlook.Application")
Set MyNameSpace = appOutl.getNameSpace("MAPI")
Set myemail = appOutl.CreateItem(0)
myemail.body = ""
'myemail.Attachments.Add "C:\Program Files\Adobe\Acrobat 7.0\PDF Output\sFileName", , , "sFileName"
'myemail.Attachments.Add "F:\Personnel Certs\Rope Access\" & I & S & "\" & I & S & ".pdf"
MailFile = ShellExecute(Application.hWndAccessApp, "Email", "F:\Personnel Certs\Rope Access\" & I & S & "\" & I & S & ".pdf", "", "C:\", 0)
'MailFile = ShellExecute(Application.hWndAccessApp, "Email", sFileName, "", "C:\", 0)
myemail.Display
Exit_MailFile:
Exit Function
Err_MailFile:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_MailFile
End Function
I am trying to email a persons pdf file by clicking on a button from their details form.
I am close but all i am getting is a blank email without the attachment inserted. I have left the other attempts commented out. When i run any of them i am getting an error saying "cannot find file"
Any ideas?
Thanks in advance
Here is the code i am using:
Private Sub EmailBtn_Click()
Dim sFileName As String
Me.MailFile (sFileName)
End Sub
********************************************
Public Function MailFile(sFileName As String)
On Error GoTo Err_MailFile
Dim I As String
Dim S As String
'I = Me.First_Name.Value
'S = Me.Surname.Value
sFileName = "F:\Personnel Certs\Rope Access\" & I & S & "\" & I & S & ".pdf"
Dim appOutl As Object
Dim MyNameSpace As Object
Dim myemail As Object
On Error GoTo Err_MailFile
Set appOutl = CreateObject("Outlook.Application")
Set MyNameSpace = appOutl.getNameSpace("MAPI")
Set myemail = appOutl.CreateItem(0)
myemail.body = ""
'myemail.Attachments.Add "C:\Program Files\Adobe\Acrobat 7.0\PDF Output\sFileName", , , "sFileName"
'myemail.Attachments.Add "F:\Personnel Certs\Rope Access\" & I & S & "\" & I & S & ".pdf"
MailFile = ShellExecute(Application.hWndAccessApp, "Email", "F:\Personnel Certs\Rope Access\" & I & S & "\" & I & S & ".pdf", "", "C:\", 0)
'MailFile = ShellExecute(Application.hWndAccessApp, "Email", sFileName, "", "C:\", 0)
myemail.Display
Exit_MailFile:
Exit Function
Err_MailFile:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_MailFile
End Function