Programmatically encrypt email (2010)

Status
Not open for further replies.

Dr. Demento

Member
Outlook version
Outlook 2010 32 bit
Email Account
IMAP
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 ;-)
 
i haven't had a chance to test it out yet. :(
 
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
P Email address auto-completes work fine on laptop, but no longer on desktop Using Outlook 2
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
A Search folder and move the email Outlook VBA and Custom Forms 0
P VBA to add email address to Outlook 365 rule Outlook VBA and Custom Forms 0
farrissf Outlook 2016 Optimizing Email Searches in Outlook 2016: Seeking Insights on Quick Search vs Advanced Search Features Using Outlook 0
D Delete selected text in outgoing email body Outlook VBA and Custom Forms 0
F Graphics in email / Mac recipient garbled Using Outlook 0
D Outlook VBA forward the selected email to the original sender’s email ID (including the email used in TO, CC Field) from the email chain Outlook VBA and Custom Forms 2
Witzker Outlook 2019 Macro to seach in all contact Folders for marked Email Adress Outlook VBA and Custom Forms 1
E Outlook 365 Save Selected Email Message as .msg File - oMail.Delete not working when SEARCH Outlook VBA and Custom Forms 0
S Email Macros to go to a SHARED Outlook mailbox Draft folder...NOT my personal Outlook Draft folder Using Outlook 2
R Outlook 365 VBA AUTO SEND WITH DELAY FOR EACH EMAIL Outlook VBA and Custom Forms 0
G Print email attachments when hit subfolder Outlook VBA and Custom Forms 1
C Spam Email? Using Outlook 2
G Automatically delete email when a condition is met Outlook VBA and Custom Forms 1
E Save Selected Email Message as .msg File - digitally sign email doesn't works Outlook VBA and Custom Forms 1
S Email was migrated from GoDaddy to Microsoft exchange. We lost IMAP ability Exchange Server Administration 1
R Outlook 365 How to integrate a third-party app with Outlook to track email and sms? Using Outlook 2
S Paperclip icon shows without attachment in email under Sent folder Using Outlook 0
B Outlook 2019 Automatically move email after assigning category Using Outlook 4
Rupert Dragwater How to permanently remove an email address Using Outlook 9
K vba code to auto download email into a specific folder in local hard disk as and when any new email arrives in Inbox/subfolder Outlook VBA and Custom Forms 0
F Auto changing email subject line in bulk Using Outlook 2
F Want to add second email to Outlook for business use Using Outlook 4

Similar threads

Back
Top