Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set "High Importance" on email sent using VBA?

I tried setting a few properties on this object to send an email with high importance, but nothing seemed to work. Here is what I tried:

objEmail.Importance = 2

objEmail.Configuration.Fields.Item("urn:schemas:mailheader:X-MSMail-Priority") = "High"      ' For Outlook 2003

objEmail.Configuration.Fields.Item("urn:schemas:mailheader:X-Priority") = 2                  ' For Outlook 2003 also

objEmail.Configuration.Fields.Item("urn:schemas:httpmail:importance") = 2

Function Send(sTo As String, sFrom As String, sSubject As String)
    Set objEmail = CreateObject("CDO.Message")
        objEmail.From = sFrom
        objEmail.To = sTo
        objEmail.Subject = sSubject
        objEmail.Textbody = emailBody
        objEmail.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "my.smtp.server"
        objEmail.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        // is there a property for high importance, outlook 2007?
        objEmail.Configuration.Fields.Update        
    objEmail.Send
End Function
like image 656
Ian R. O'Brien Avatar asked Jul 21 '10 17:07

Ian R. O'Brien


People also ask

Can you use VBA to send email?

In VBA, to send emails from Excel, we can automatically automate our mailing feature to send emails to multiple users at a time. However, to do so, we need to remember that we may do it by outlook, another product of outlook, so we need to enable outlook scripting in VBA. Once done, we use the .

What does high importance do in Outlook?

Setting messages to high importance notifies recipients that the message is urgent and needs attention. If the message is an FYI, or non-work related topics, you can set the low importance indicator.

How do I create an email macro?

To create a new macro In Outlook, on the Developer tab of the Microsoft Office Fluent ribbon, click Visual Basic. In the Project window, double-click the module you want to contain the macro. On the Insert menu, click Procedure. In the Name box, type a name for the macro.


2 Answers

It's been a while since I worked with Outlook and VBA but I still have various cheat sheets and links. I dug this up; hope it helps!

Try setting the .Importance property in your mail object

with myEmail
    'can be olImportanceNormal, olImportanceHigh or olImportanceLow
    .Importance = olImportanceNormal
    .Subject = "Subject line"
    .Body = "Body Content"
end with
like image 122
L1Wulf Avatar answered Dec 30 '22 22:12

L1Wulf


.Importance = 2 (for anyone looking in 2015).

like image 27
JustoShow Avatar answered Dec 30 '22 21:12

JustoShow