I've tried the code below.
Code:
Dim CM As ASPENCRYPTLib.ICryptoManager
CM = New ASPENCRYPTLib.CryptoManager()
Dim Mail As ASPEMAILLib.IMailSender
Mail = New ASPEMAILLib.MailSender()
Dim strSubject As String
Dim strFrom As String
Dim strTo As String
Dim strBody As String
Dim cert As String
strSubject = "Test"
strFrom = "josh@test.com"
strTo = "josh@test.com"
strBody = "test123"
cert = "secureemail.cer"
Dim Context As ASPENCRYPTLib.ICryptoContext = CM.OpenContext("SecureMail", True)
Dim RecipientCert As ASPENCRYPTLib.ICryptoCert = CM.ImportCertFromFile(Server.MapPath(cert))
Dim Msg As ASPENCRYPTLib.ICryptoMessage = Context.CreateMessage
Msg.AddRecipientCert(RecipientCert) ' repeat if necessary
'' Send Encrypted Message
Mail.Host = "mail.test.com"
Mail.Username = "josh@test.com"
Mail.Password = "test"
Mail.Subject = strSubject
Mail.From = strFrom
Mail.FromName = strFrom
Mail.AddAddress(strTo)
Mail.Body = strBody
Mail.IsHTML = True
Mail.SendEncrypted(Msg) ' Use CryptoMessage object
But I get "System.Security.SecurityException: System.Security.Permissions.SecurityPermission" when defining CM = New ASPENCRYPTLib.CryptoManager()
Any ideas?
Josh
Bookmarks