• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 93
  • Last Modified:

smtp replyto MailAddress

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

screen print
0
lrbrister
Asked:
lrbrister
  • 7
  • 4
  • 3
  • +1
1 Solution
 
John HurstBusiness 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
 
lrbristerAuthor Commented:
I am sending emails to an SMTP API at SendGrid

I need a different reply to than the from address
0
 
John HurstBusiness Consultant (Owner)Commented:
Can you indicate how you set?  Not all such setups allow "Reply to"
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
lrbristerAuthor 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
 
John HurstBusiness Consultant (Owner)Commented:
Thanks. When you insert a verifiable in replyToAddress = and run the code, what error do you get?
0
 
lrbristerAuthor 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
 
John HurstBusiness 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
 
lrbristerAuthor 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
 
lrbristerAuthor 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
 
lrbristerAuthor 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
 
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
 
lrbristerAuthor Commented:
Bingo!
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 7
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now