PDA

View Full Version : [SOLVED] Excel vba set email on outlook to high importance



Mitchell
07-11-2017, 01:14 PM
My goal is to have the emails that I am sending automatically from excel send in outlook with high importance. When I run my code even though in the code I set the importance of the email to high Outlook still sends the email using low importance. I don't know how to fix this. I have tried setting a rule on outlook but have not been successful. I have also tried changing settings in Outlook but have also been unsuccessful. Any help would be much appreciated!

My code:


Sub send_outlook_mail(tofield As String, _
ccfield As String, _
subjectfield As String, _
body As String, _
htmlformat As Boolean, _
attachment As String, _
displayfirst As Boolean)

'This version should only be used when you have installed a copy of MS Outlook
'on your computer. It is more powerful than the above version and it lets
'you include attachments (provide the full path the file) and use HTML format if you like.


Set objOL = CreateObject("Outlook.Application")
Set objEmail = objOL.CreateItem(olMailItem)


With objEmail


.to = tofield

.CC = ccfield

.subject = subjectfield

If htmlformat Then
.HTMLBody = body
Else
.body = body
End If

.Importance = olImportanceHigh

If attachment <> "" Then
.attachments.Add attachment
End If

.Recipients.ResolveAll

If displayfirst Then
.Display
Else
.Send
End If

End With


'MsgBox "Email Sent", vbOKOnly + vbInformation, "Send Mail Program"


End Sub

Leith Ross
07-11-2017, 01:55 PM
Hello Mitchell,

Because you are using Late Binding to Outlook, the constants are not available.

Change this...


.Importance = olImportanceHigh


To This...


.Importance = 2

Mitchell
07-11-2017, 02:11 PM
Leith Ross,

Thanks so much! Works great!

Mitchell