如何在使用 VBA 发送的电子邮件上设置“高重要性”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3302036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 10:39:22  来源:igfitidea点击:

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

emailvbacdo.message

提问by Ian R. O'Brien

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

回答by L1Wulf

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!

我使用 Outlook 和 VBA 已经有一段时间了,但我仍然有各种备忘单和链接。我挖了这个;希望能帮助到你!

Try setting the .Importance property in your mail object

尝试在邮件对象中设置 .Importance 属性

with myEmail
    'can be olImportanceNormal, olImportanceHigh or olImportanceLow
    .Importance = olImportanceNormal
    .Subject = "Subject line"
    .Body = "Body Content"
end with

回答by JustoShow

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

.Importance = 2(对于 2015 年的任何人)。

回答by user2886369

From Remou's linkin the comments, this works for Outlook 2010 via VBA:

从评论中的Remou 链接,这适用于通过 VBA 的 Outlook 2010:

cdoMessage.Fields.Item(cdoImportance) = cdoHigh