How to add a DKIM signature to classic ASP email sent using CDO

1.9k Views Asked by At

Using something like the below, is it possible to add a header for a DKIM signature? From what I've been reading, it doesn't look like it.. Why not?

Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields

Const cdoSendUsingPort = 2

With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort 
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "server"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic 
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "abc"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "123"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With

With iMsg
Set .Configuration = iConf
.To = recipient
.From = "[email protected]"
.Subject = "subject"
.HTMLBody = "body"
.Send
End With
1

There are 1 best solutions below

0
On

If you already have the signature, you could add it to the Fields property of your iMsg object. I've done something similar before to set the "Reply To" and "Return Receipts" addresses:

.Fields("urn:schemas:mailheader:disposition-notification-to") = "[email protected]"
.Fields("urn:schemas:mailheader:return-receipt-to") = "[email protected]" 

You could do the same to add any custom header, in your case the DKIM signature. Your iMsg object becomes:

With iMsg
  Set .Configuration = iConf
  .To = recipient
  .From = "[email protected]"
  .Subject = "subject"
  .HTMLBody = "body"
  .Fields("urn:schemas:mailheader:DKIM-Signature") = "YOUR_SIGNATURE_HERE"
  .Send
End With

I hope that helps.