Programmatically encrypt email (2010)

Status
Not open for further replies.

Dr. Demento

Member
OS Version(s)
  1. Windows
Outlook version
Outlook 365 64 bit
Email Account
Office 365 Exchange
From what I've seen, past versions of Outlook did not have the capability of programatically signing/encrypting email; is this still the case for Outlook 2010 (32- or 64-bit)??

If that's still the case, would it be possible to use the code found here or here and turn it on/off programatically?? If so, I'm hoping that would have the same outcome as my original intent. Or, did I misunderstand the purpose of this code?

Thanks so much.
 
Alternatively, would the code found here allow me turn on/off encryption for specified emails?
 
You'll need to use a macro that uses PR_SECURITY_FLAGS - either the itemsend macro that signs it as its sent or the msdn macro - you can trigger it from another macro or by clicking a button on the ribbon.
 
Alternatively, would the code found here allow me turn on/off encryption for specified emails?
FWIW, either this macro (which is the 'msdn one') or this itemsend macro can handle enabling it only for specific messages - the msdn macro can be assigned a button or called by another macro or you can use an if statement in the item send, such as:
if left(lcase(item.subject), 6) = "secure" then
' encrypt
end if
 
The MSDN macro is throwing error 438 (I think I read something about ActiveInspector not working in Office 2010??).

Alternatively, using the ItemSend macro is throwing error 424 - Object required

Everything goes off without a hitch until "SignAndEncrypt (objMail)" Can you assist? What am I doing wrong?

I'm using Office 2010; this code is reading values in a spreadsheet and calling Outlook. I have the Outlook 14.0 Object Library reference checked.

Code:
Dim objOutlook As New Outlook.Application  ' Early binding || https:msdn.microsoft.com/en-us/library/ff458119(v=office.11).aspx#odc_office_UseExcelObjectModeltoSendMail_MailingWorkbookasEmailAttachment
Dim objMail As Outlook.MailIte

For Each rngEntry In rngSPPM
    If IsFile(rngEntry.Offset(5, 0).Value & rngEntry.Offset(4, 0).Value) = True Then
      Set objMail = objOutlook.CreateItem(olMailItem)  ' Early binding
  '    Set objMail = objOutlook.CreateItem(0)  ' Late binding
      With objMail
        .DeferredDeliveryTime = SendAt  ' http:www.experiglot.com/2013/09/25/sending-delayed-emails-in-outlook-using-excel/
        .BodyFormat = olFormatPlain  ' http:www.vbaexpress.com/forum/archive/index.php/t-38578.html
        .To = rngEntry.Value
        .CC = carbon1.Value
        .Subject = rngEntry.Offset(1, 0).Value
        .Body = rngEntry.Offset(2, 0).Value & vbNewLine & vbNewLine & Signature
        .Attachments.Add rngEntry.Offset(5, 0).Value & _
                         rngEntry.Offset(4, 0).Value
        .Display ' .Send or .Save  ' ~~ Other Outlook actions for emails
      End With
      If mod_Exists.ExactWordInString(objMail.Subject, "Reconciliation") = True Then SignAndEncrypt (objMail)
    Else
      On Error Resume Next
    End If
  Next rngEntry

Thanks so much for your help!!
 
Sorry it took so long to get to this, everytime I'd think "i need to put this in my VM and check it', I'd get side tracked. :(

Does it stop on any line? Comment out error checking lines if necessary.

> Dim objMail As Outlook.MailIte
you're missing the M in item.
 
Diane,

No worries - I'm just grateful for the help. The missing M is a copy/paste error; it's there in 'real-life' ;-)

I've altered the code a bit; I call it using

Code:
If mod_Exists.ExactWordInString(objMail.Subject, "Reconciliation") = True _
  Then Call Sign_Encrypt(objMail)
where
Code:
Set objMail = objOutlook.CreateItem(olMailItem)

and get the error (#287) when defining oProp (=0)

Code:
Private Sub Sign_Encrypt(ByVal item As Object, Optional Cancel As Boolean)
' ~~ How to sign or encrypt a message programmatically from OOM
' https://support.microsoft.com/en-us/kb/2636465

  Dim ulFlags As Object
  Dim oProp As Long

  Const PR_SECURITY_FLAGS = "http://schemas.microsoft.com/mapi/proptag/0x6E010003"
  oProp = CLng(item.PropertyAccessor.GetProperty(PR_SECURITY_FLAGS))  '<~~~ Error 287 - application or object defined error
  ulFlags = 0
  ulFlags = ulFlags Or &H1 ' Add the encrypted flag
  ulFlags = ulFlags Or &H2 ' Add the signed flag
  item.PropertyAccessor.SetProperty PR_SECURITY_FLAGS, ulFlags

  Set item = Nothing

End Sub

BTW, the call statement and Sign_Encrypt are in the same module in Excel (Excel/Outlook 2010).
 
Just curious if anyone had any insights as to my issues (see avatar) or my Outlook problem ;-)
 
No worries; just curious if anyone else could offer some insights. You can't solve ALL the world's Outlook problems; gotta leave some for other folks! :D
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
J VBA Cannot programmatically input or change Value for User Defined field Using Outlook 1
B Programmatically force html send and insert clipboard contents into body Outlook VBA and Custom Forms 0
oliv- Reduce the size of picture attachments: programmatically Outlook VBA and Custom Forms 3
B Adding controls programmatically Using Outlook 1
M programmatically make all Appointmentitem olResource Attendees unsendable Using Outlook 1
S Programmatically accessing Outlook Calendar data Using Outlook 1
R Send appointments data to a Form programmatically Outlook VBA and Custom Forms 2
M How to connect to SQL DB from outlook programmatically? Outlook VBA and Custom Forms 1
B Programmatically scheduling WebEx meetings through Outlook Outlook VBA and Custom Forms 1
N Help in programmatically setting formatting in an AppointmentItem Outlook VBA and Custom Forms 3
K Programmatically accessing Outlook properties Outlook VBA and Custom Forms 3
V How to programmatically set "Display reminders and tasks frm pstfolder Outlook VBA and Custom Forms 1
R Displaying a field from the field chooser programmatically Outlook VBA and Custom Forms 1
M How to programmatically select a outlook search folder? Outlook VBA and Custom Forms 1
M How to install custom mapi form programmatically? Outlook VBA and Custom Forms 1
A Programmatically duplicating BCM's "Link to Record" function BCM (Business Contact Manager) 2
B Accessing Outlook 2003 Signature Programmatically using C# Outlook VBA and Custom Forms 6
L Programmatically moving between pages in a form Outlook VBA and Custom Forms 2
S Programmatically bring up Advanced Find for contacts? Outlook VBA and Custom Forms 1
S assign task programmatically Outlook VBA and Custom Forms 2
S do Reply, Reply to All, Forward programmatically Outlook VBA and Custom Forms 2
U unable to encrypt email Using Outlook 9
R State of encrypt and sign button for a saved mail?(draft) Outlook VBA and Custom Forms 3
R About state of encrypt and sign button for outlook? Outlook VBA and Custom Forms 7
R Encrypt and sign button while word is editor for outlook? Outlook VBA and Custom Forms 6
L Hide Selected Email Address from Address Book Using Outlook 5
Y QQ on Scheduled Delivery of an Email Using Outlook 0
T Replace Text in Email Subject Outlook VBA and Custom Forms 3
Rupert Dragwater Cannot reestablish gmail (email address) account in Outlook 365 Using Outlook 11
M Outlook 365 adding standard message in body of template email Outlook VBA and Custom Forms 3
E Create Rule to Forward Email if Subject Begins With Using Outlook 2
V iCloud For Windows v15.x - Missing Email Features ? Using Outlook 4
M Thunderbird email client - I wonder Using Outlook 1
D Outlook Desktop App Email Software Using Outlook 0
P Email and calendar entry text now shifts right about 3 tabs worth of space Using Outlook 1
J Outlook macro to run before email is being send Outlook VBA and Custom Forms 3
T Outlook 2010 Creating a email 'Group' in OL 2010 Using Outlook 2
D Send email from Outlook Alias using Mac? Using Outlook 0
T How to set Default FONT for Email composing ? Using Outlook 0
H Finding text in open email Outlook VBA and Custom Forms 12
T Why do Outlook Desktop 2021 tasks from my wife's email show up in my task pane? Using Outlook 2
A Opening a link from an email automatically Outlook VBA and Custom Forms 0
D Outlook 2021 New email reminder Using Outlook.com accounts in Outlook 1
Rupert Dragwater How do I remove an email ending with @gmail.com Using Outlook 4
M A plug in (or method) to keep email message formatting after it expires Using Outlook 1
L VBA to Triage Incoming Email Outlook VBA and Custom Forms 0
R Legacy Outlook on Mac Email Cache Using Outlook 0
P Email address auto-completes work fine on laptop, but no longer on desktop Using Outlook 3
S Create Outlook Task from Template and append Body with Email Body Outlook VBA and Custom Forms 4
H Copying email address(es) in body of email and pasting in To field Outlook VBA and Custom Forms 1

Similar threads

Back
Top