A
arnold
I am trying to program Access to automatically attach files to an
email if there is a file at a specified path. The following code
works perfectly until the second If Not Missing statement. How can I
make Access skip the second attachment if there is no such file
there? I would like for it to attach both assuming there are two
files. I am sure this is an easy fix, but I cannot get past it. Any
help would be greatly appreciated!
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim objOutlookAttach2 As Outlook.Attachment
Dim strFolderPath As String
Dim superName As String
AttachmentPath = "I:\Applicants\Applications\" & "SDOC" &
Me.AppFileName & ".pdf"
Attachment2Path = "I:\Applicants\Interview\" & "SDOC" & Me.AppFileName
& ".pdf"
Me.SentSupervisor = Date
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add(Me.Combo197)
objOutlookRecip.Type = olTo
.Subject = Me.FirstName & " " & Me.LastName
.Body = "This is a potential new hire. Take a look at the
application and let me know if you have any questions. If there are
two files attached, one i " & Me.Notes & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
If Not IsMissing(AttachmentPath2) Then
Set objOutlookAttach2 = .Attachments.Add(Attachment2Path)
email if there is a file at a specified path. The following code
works perfectly until the second If Not Missing statement. How can I
make Access skip the second attachment if there is no such file
there? I would like for it to attach both assuming there are two
files. I am sure this is an easy fix, but I cannot get past it. Any
help would be greatly appreciated!
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim objOutlookAttach2 As Outlook.Attachment
Dim strFolderPath As String
Dim superName As String
AttachmentPath = "I:\Applicants\Applications\" & "SDOC" &
Me.AppFileName & ".pdf"
Attachment2Path = "I:\Applicants\Interview\" & "SDOC" & Me.AppFileName
& ".pdf"
Me.SentSupervisor = Date
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add(Me.Combo197)
objOutlookRecip.Type = olTo
.Subject = Me.FirstName & " " & Me.LastName
.Body = "This is a potential new hire. Take a look at the
application and let me know if you have any questions. If there are
two files attached, one i " & Me.Notes & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
If Not IsMissing(AttachmentPath2) Then
Set objOutlookAttach2 = .Attachments.Add(Attachment2Path)