Email Encryption code vba

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,227
Office Version
  1. 2010
Platform
  1. Windows
Hi good morning, hope you can help me please, i have the code below where i have put an encryption in for emails, but i am getting an error on the line below please can you help?

I get an eror on this line -
Code:
aEmail.PropertyAccessor.SetProperty PR_SECURITY_FLAGS, (ulFlags)

VBA Code:
Private Sub CommandButton2_Click()
Const PR_SECURITY_FLAGS = "http://schemas.microsoft.com/mapi/proptag/0x6E010003%22"
Dim aOutlook As Object
Dim aEmail As Object
Dim ulFlags As Integer
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String
Dim rngDataToEmail As Range

    Set aOutlook = CreateObject("Outlook.Application")
    Set aEmail = aOutlook.CreateItem(0)


 ulFlags = ulFlags Or &H1 ' SECFLAG_ENCRYPTED

    aEmail.PropertyAccessor.SetProperty PR_SECURITY_FLAGS, (ulFlags)

    With Sheets("Work Issue")
        Set rngDataToEmail = .Range("B1:R" & .Range("B" & Rows.Count).End(xlUp).Row)
    End With


    
aEmail.HTMLBody = "<html><body><p>Hi " & Me.TextBox9.Value & "</p>" _
                    & "<p>" & Me.ComboBox2.Value & "</p>" _
                    & "<p>" & Me.ComboBox3.Value & "</p>" _
                    & "<p>" & Me.TextBox1.Value & "</p>" & RangetoHTML(rngDataToEmail) _
                    & "<p>Many Thanks</p>" _
                    & "<p>Complex Team</p>" _
                    & "</body></html>"


    aEmail.Recipients.Add (UserForm1.TextBox2.Value)
    aEmail.CC = (UserForm1.TextBox3.Value)
    aEmail.BCC = ""
    aEmail.Subject = (UserForm1.TextBox6.Value) & (UserForm1.TextBox8.Value) & (UserForm1.ComboBox4.Value)
    aEmail.Display

    Unload Me


End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
The %22 on the end of the namespace identifier looks wrong to me.
 
Upvote 0
It would help if you said what the error actually is?
 
Upvote 0

Forum statistics

Threads
1,213,495
Messages
6,113,992
Members
448,538
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top