So I have recently updated from office 2010 to office 2013. I previously had a macro which send out personalised emails to a list of recipients and attached a series of files. This worked perfectly in 2010 but is throwing up an error in 2013, looking for some advice with this.
Above is the VBA code used. The error being given is as follows "Method '.SentOnBehalfOfName' of object '_MailItem' failed". I can't for the life of me understand why this would not work in 2013, need to send out emails asap so any advice on the matter would be much appreciated!!!
Thanks
Code:
Sub EmailMacro()
Dim OutApp As Object
Dim OutMail As Object
Dim Temp As String
Temp = Range("OutTemp")
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItemFromTemplate("C:\Users\labunimeh\Documents\Client Work\FS\Outlook Template KSN v03.msg")
With OutMail
.SentOnBehalfOfName = Range("E_From")
.To = Range("MailTo")
.CC = Range("MailCC")
'.BCC = Range("MailBCC)
.Subject = Range("Subject")
'.HTMLBody = "<body>" & Range("BodyText") & "</body>" & OutMail.HTMLBody
.Importance = Range("Importance")
If Range("Attach1") = "Yes" Then
.Attachments.Add (Range("Attachfile1"))
End If
On Error Resume Next
If Range("attach2") = "Yes" Then
.Attachments.Add (Range("AttachFile2"))
End If
On Error Resume Next
If Range("attach3") = "Yes" Then
.Attachments.Add (Range("AttachFile3"))
End If
On Error Resume Next
If Range("attach4") = "Yes" Then
.Attachments.Add (Range("AttachFile4"))
End If
On Error Resume Next
If Range("send") = "Send" Then
.Send
ElseIf Range("send") = "Save" Then
.Save
Else
.Display
End If
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Above is the VBA code used. The error being given is as follows "Method '.SentOnBehalfOfName' of object '_MailItem' failed". I can't for the life of me understand why this would not work in 2013, need to send out emails asap so any advice on the matter would be much appreciated!!!
Thanks