VB.NET
VB.NET
Amazon SES v2: Verify a sending domain with Easy DKIM
See more Amazon SES Examples
Use a domain you control. Run once to create the regional identity, publish the returned CNAMEs with your DNS provider, then set checkExisting to true and run again to read the status. The target suffix comes from SES. If your DNS provider appends the domain automatically, enter just the relative record name.
CreateEmailIdentity · GetEmailIdentity · Easy DKIM records
Chilkat VB.NET Downloads
Dim success As Boolean = False
' Assumes Chilkat is unlocked. See Global Unlock Sample.
success = False
Dim domainName As String = "example.com"
Dim checkExisting As Boolean = False
' Use the same AWS Region for the identity, endpoint, and Signature Version 4.
Dim region As String = "us-west-2"
Dim host As New Chilkat.StringBuilder
host.Append("email.")
host.Append(region)
host.Append(".amazonaws.com")
Dim signer As New Chilkat.AuthAws
' Supply the credentials from your application's credential provider.
signer.AccessKey = "AWS_ACCESS_KEY_ID"
signer.SecretKey = "AWS_SECRET_ACCESS_KEY"
signer.Region = region
signer.ServiceName = "ses"
Dim connection As New Chilkat.Socket
connection.RequireSslCertVerify = True
success = connection.Connect(host.GetAsString(),443,True,10000)
If (success <> True) Then
Debug.WriteLine(connection.LastErrorText)
Exit Sub
End If
Dim rest As New Chilkat.Rest
success = rest.UseConnection(connection,False)
If (success <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
success = rest.SetAuthAws(signer)
If (success <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
' For temporary AWS credentials, supply the session token from the same provider.
Dim sessionToken As String = ""
If (sessionToken <> "") Then
rest.AddQueryParam("X-Amz-Security-Token",sessionToken)
End If
Dim responseText As String = ""
If (checkExisting = True) Then
Dim path As New Chilkat.StringBuilder
path.Append("/v2/email/identities/")
path.Append(domainName)
responseText = rest.FullRequestNoBody("GET",path.GetAsString())
Else
Dim identity As New Chilkat.JsonObject
identity.UpdateString("EmailIdentity",domainName)
rest.AddHeader("Content-Type","application/json")
responseText = rest.FullRequestString("POST","/v2/email/identities",identity.Emit())
End If
If (rest.LastMethodSuccess <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
If (rest.ResponseStatusCode <> 200) Then
Debug.WriteLine("SES returned HTTP " & rest.ResponseStatusCode & " " & responseText)
Exit Sub
End If
Dim response As New Chilkat.JsonObject
success = response.Load(responseText)
If (success <> True) Then
Debug.WriteLine(response.LastErrorText)
Exit Sub
End If
Debug.WriteLine("DKIM status: " & response.StringOf("DkimAttributes.Status"))
Debug.WriteLine("Verified for sending: " & response.BoolOf("VerifiedForSendingStatus"))
Dim count As Integer = response.SizeOfArray("DkimAttributes.Tokens")
If (count < 1) Then
Debug.WriteLine("No Easy DKIM tokens were returned. Check this identity's DKIM configuration.")
Exit Sub
End If
If (response.HasMember("DkimAttributes.SigningHostedZone") <> True) Then
Debug.WriteLine("Find the CNAME targets for this identity in the SES console.")
Exit Sub
End If
Dim zone As String = response.StringOf("DkimAttributes.SigningHostedZone")
Dim i As Integer = 0
While (i < count)
response.I = i
Dim token As String = response.StringOf("DkimAttributes.Tokens[i]")
Debug.WriteLine(token & "._domainkey." & domainName & " CNAME " & token & "." & zone)
i = i + 1
End While