Larry Brister
asked on
smtp replyto MailAddress
What is the above from and where do you enter the setting in Outlook? I assumed Outlook. In any event, what are you setting?
ASKER
I am sending emails to an SMTP API at SendGrid
I need a different reply to than the from address
I need a different reply to than the from address
Can you indicate how you set? Not all such setups allow "Reply to"
ASKER
This is pretty much all the code... and imports
the variable transportWeb is the actual api i'm consuming
the variable transportWeb is the actual api i'm consuming
Imports System.Data.SqlClient
Imports System.Net.Mail
Imports System.IO
Imports System.Net
Imports SendGrid
Imports Newtonsoft.Json
Imports System.Configuration
Dim EmailFrom As String = ""
Dim Emailx As String = ""
' Dim Mailserverx As String = ""
EmailFrom = dR4("FromName") & "-" & "<" & "us@mydomain.com" & " > """
Emailx = dR4("EmailAddress").ToString()
replyToAddress = dR4("ReplyAddress").ToString() + ""
Dim recipients As New List(Of [String])() From {dR4("EmailAddress").ToString() + ""}
Dim customArgs As New Dictionary(Of String, String)()
customArgs.Add("campaign_id", dR4("campaignid").ToString() + "")
customArgs.Add("Customer_ID", dR4("Customer_ID").ToString() + "")
Dim myMessage = New SendGridMessage()
myMessage.AddTo(recipients)
myMessage.From = New MailAddress(fromAddress)
myMessage.Subject = EmailSubject
myMessage.Html = HTML
myMessage.AddUniqueArgs(customArgs)
Dim credentials = New NetworkCredential(sgUsername, sgPassword)
' Create a Web transport for sending email.
Dim transportWeb = New Web(credentials)
' Send the email.
transportWeb.Deliver(myMessage)
Thanks. When you insert a verifiable in replyToAddress = and run the code, what error do you get?
ASKER
The error is in my screen print in the original question in the console window
Essentially Value of 'MailAddress' cannot be converted to 'MailAddress()'
Essentially Value of 'MailAddress' cannot be converted to 'MailAddress()'
Thanks. That was confusing for me to sort out from the screen print. So the function you want is not supported.
It would appear that the ReplyTo property in SendGrid expects an array of addresses, not a single address.
ASKER
Shaun... how do I set that array?
myMessage.ReplyToList.Add( replyToAdd ress)
So, remove whole ReplyTo line
So, remove whole ReplyTo line
You can use the New Array() constructor when you want an array that is not typed to a specific data type, or you can use New String ().
To create and assign all in one line, you can do:
myMessage.ReplyTo = New String() { replyToAddress }
To create and assign all in one line, you can do:
myMessage.ReplyTo = New String() { replyToAddress }
ASKER
Kimputer
myMessage is a SendGridMessage()
Dim myMessage = New SendGridMessage()
Insite of that...
....
Public Property From As MailAddress
Public Property ReplyTo As MailAddress()
Inside of that...
Public Class MailAddress
Public Sub New(address As String)
Public Sub New(address As String, displayName As String)
Public Sub New(address As String, displayName As String, displayNameEncoding As Encoding)
myMessage is a SendGridMessage()
Dim myMessage = New SendGridMessage()
Insite of that...
....
Public Property From As MailAddress
Public Property ReplyTo As MailAddress()
Inside of that...
Public Class MailAddress
Public Sub New(address As String)
Public Sub New(address As String, displayName As String)
Public Sub New(address As String, displayName As String, displayNameEncoding As Encoding)
ASKER
I was told to set replyto to this????
How does that transpose in my sub?
'reply_to': {
'email': 'sam.smith@example.com',
'name': 'Sam Smith'
}
How does that transpose in my sub?
'reply_to': {
'email': 'sam.smith@example.com',
'name': 'Sam Smith'
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Bingo!