Hello all,
I have a script I built a couple years ago which creates emails in MS Outlook with predefined subject lines, addressees, and attachments. The end user can either run it to display or send. For 2 years it worked fine as I was referencing a simple shared folder for the required attachments. However, when my organization rolled out Sharepoint and upgraded the Office version we were on, the attachments started displaying as failed. I did of course update the file path to reference the Sharepoint Library the attachments were contained in. I do have permissions to that library and when I manually try to navigate to those locations, I have no problem doing so. The email still generates, but the file attachments display as "Download Failed" When I double click on them, it gives me a Retry option and when I select that the download actually succeeds.
My code is below for your reference, and I'm attaching a screenprint of the email output.
Sub Financial()
Dim objOutlook As Object
Dim objMail As Object
Dim rngTo As Range
Dim rngSubject As Range
Dim rngBody As Range
Dim rngAttach1 As Range
Dim rngAttach2 As Range
Dim emailTo As String
Dim emailBody As String
Dim emailSubject As String
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
emailTo = ""
For Each cell In Range("FinancialRateSheet")
If cell.Value <> "" Then emailTo = emailTo & cell.Value & "; "
Next
emailbody1 = Range("Financial_Message").Value
emailBody3 = "<br><br>" & "<img src='C:\TempPath\logo.jpg'>"
emailSubject = ""
For Each cell In Range("Financial_Subject")
If cell.Value <> "" Then emailSubject = emailSubject & cell.Value
Next
With ActiveSheet
Set rngAttach1 = .Range("C6")
Set rngAttach2 = .Range("L1")
End With
With objMail
.To = ""
.BCC = emailTo
.Subject = emailSubject
.HTMLbody = emailbody1 & emailbody2 & emailBody3 & "<br>" & .HTMLbody
.Attachments.Add rngAttach1.Value
.Attachments.Add rngAttach2.Value
.Display
End With
Set objOutlook = Nothing
Set objMail = Nothing
Set rngTo = Nothing
Set rngSubject = Nothing
Set rngBody = Nothing
Set rngAttach1 = Nothing
Set rngAttach2 = Nothing
End Sub
Bookmarks