Avatar of Larry Brister
Larry Brister
Flag for United States of America asked on

SendGrid SMTP Send Mail Message .Net

I am getting the following message on my ReplyTo line below.

Value of type 'MailAddress' cannot be converted to 'MailAddress()'.
Without that mail sends perfectly fine however.

Little help?
            Dim recipients As New List(Of [String])() From {Emailx + ""}
            Dim customArgs As New Dictionary(Of String, String)()
            customArgs.Add("campaign_id", "ewCID9999")
            customArgs.Add("Customer_ID", "ewCUSID123")

            Dim myMessage = New SendGridMessage()
            myMessage.AddTo(recipients)
            myMessage.From = New MailAddress(fromAddress) 'fromAddress
            Dim tReply = New MailAddress("myaddress@mydomain.com")

            myMessage.Subject = "TEST NEW USER"
            myMessage.Html = "TEST HTML <br /><br /><br />LB"
            myMessage.AddUniqueArgs(customArgs)
            myMessage.ReplyTo = tReply
            Dim credentials = New NetworkCredential(sgUsername, sgPassword)
            ' Create a Web transport for sending email.
            Dim transportWeb = New Web(credentials)

Open in new window


SP
Visual Basic.NET.NET Programming* SMTP

Avatar of undefined
Last Comment
Larry Brister

8/22/2022 - Mon
Kimputer

Type is wrong, fix it like this:

        Dim replyaddresses As New List(Of MailAddress)
        Dim tReply = New MailAddress("myaddress@mydomain.com")
        replyaddresses.Add(tReply)
        myMessage.ReplyToList(replyaddresses)

Open in new window

ASKER CERTIFIED SOLUTION
Larry Brister

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Larry Brister

ASKER
Found my own solution.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes