vbscriptexchange-servercdo.messageconfidential

How to send a Confidential email using VBScript


I have been searching on-line on how to send an email with attachment as confidential. I was already able to create a script to be able to send an email with an attachment but I can't figure out how to send it as confidential.

I would appreciate if somebody can help me how to set email sensitivity in VBScript.

Here's my code:

Call Email

sub Email

    Set objEmail = CreateObject("CDO.Message")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objEmail.From = "myemail"
    objEmail.To = "SendToEmail"
    ObjEmail.Subject = "Email Title"
    ObjEmail.Textbody = "Email Body"
    objEmail.AddAttachment "C:\Temp\ERSD\dchmar_" & sDate & ".txt"
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="xx.xx.xx.xx"
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/exchange/sensitivity") = 3
    objEmail.Configuration.Fields.Update
    objEmail.Send

End sub

Solution

  • Could you try this?

    It's unknown if you have some custom headers. So check the headers in Outlook to see if those match with what I've posted below but I believe that should accomplish what you're asking.

    Set objEmail = CreateObject("CDO.Message")
    Set objEmailConf = CreateObject("CDO.Configuration")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objEmail.From = "myemail"
    objEmail.To = "SendToEmail"
    ObjEmail.Subject = "Email Title"
    ObjEmail.Textbody = "Email Body"
    objEmail.AddAttachment "C:\Temp\ERSD\dchmar_" & sDate & ".txt"
    objEmailConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objEmailConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="xx.xx.xx.xx"
    objEmailConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    'objEmailConf.Fields.Item("http://schemas.microsoft.com/exchange/sensitivity") = 3
    objEmailConf.Fields.Update
    objEmail.Configuration.Fields.Item("urn:schemas:mailheader:Sensitivity") = "Company-Confidential"
    objEmail.Configuration.Fields.Update
    objEmail.Send