Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

smtp replyto MailAddress

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

User generated image
Avatar of John
John
Flag of Canada image

What is the above from and where do you enter the setting in Outlook? I assumed Outlook. In any event, what are you setting?
Avatar of Larry Brister

ASKER

I am sending emails to an SMTP API at SendGrid

I need a different reply to than the from address
Can you indicate how you set?  Not all such setups allow "Reply to"
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

Thanks. When you insert a verifiable in replyToAddress = and run the code, what error do you get?
The error is in my screen print in the original question in the console window

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.
Avatar of Shaun Kline
It would appear that the ReplyTo property in SendGrid expects an array of addresses, not a single address.
Shaun... how do I set that array?
Avatar of Kimputer
Kimputer

myMessage.ReplyToList.Add(replyToAddress)

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 }
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)
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'
  }
ASKER CERTIFIED SOLUTION
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Bingo!