smtp replyto MailAddress

What am I missing on my reply to line in the attached screen print?

screen print
Larry Bristersr. DeveloperAsked:
Who is Participating?
 
Shaun KlineLead Software EngineerCommented:
The MailAddress has three constructors. The one that takes two strings can be used to assign email address and DisplayName.
So:
New MailAddress("sam.smith@example.com", "Sam Smith")

To add it as a ReplyTo on your MailMessage object, try this:

myMessage.ReplyTo = { New MailAddress("sam.smith@example.com", "Sam Smith") }
0
 
JohnBusiness Consultant (Owner)Commented:
What is the above from and where do you enter the setting in Outlook? I assumed Outlook. In any event, what are you setting?
0
 
Larry Bristersr. DeveloperAuthor Commented:
I am sending emails to an SMTP API at SendGrid

I need a different reply to than the from address
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
JohnBusiness Consultant (Owner)Commented:
Can you indicate how you set?  Not all such setups allow "Reply to"
0
 
Larry Bristersr. DeveloperAuthor Commented:
This is pretty much all the code... and imports
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)

Open in new window

0
 
JohnBusiness Consultant (Owner)Commented:
Thanks. When you insert a verifiable in replyToAddress = and run the code, what error do you get?
0
 
Larry Bristersr. DeveloperAuthor Commented:
The error is in my screen print in the original question in the console window

Essentially Value of 'MailAddress' cannot be converted to 'MailAddress()'
0
 
JohnBusiness Consultant (Owner)Commented:
Thanks. That was confusing for me to sort out from the screen print. So the function you want is not supported.
0
 
Shaun KlineLead Software EngineerCommented:
It would appear that the ReplyTo property in SendGrid expects an array of addresses, not a single address.
0
 
Larry Bristersr. DeveloperAuthor Commented:
Shaun... how do I set that array?
0
 
KimputerCommented:
myMessage.ReplyToList.Add(replyToAddress)

So, remove whole ReplyTo line
0
 
Shaun KlineLead Software EngineerCommented:
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 }
0
 
Larry Bristersr. DeveloperAuthor Commented:
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)
0
 
Larry Bristersr. DeveloperAuthor Commented:
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'
  }
0
 
Larry Bristersr. DeveloperAuthor Commented:
Bingo!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.