Solved

smtp replyto MailAddress

Posted on 2016-08-17
15
68 Views
Last Modified: 2016-08-17
What am I missing on my reply to line in the attached screen print?

screen print
0
Comment
Question by:lrbrister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 3
  • +1
15 Comments
 
LVL 95

Expert Comment

by:John Hurst
ID: 41759327
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
 

Author Comment

by:lrbrister
ID: 41759334
I am sending emails to an SMTP API at SendGrid

I need a different reply to than the from address
0
 
LVL 95

Expert Comment

by:John Hurst
ID: 41759339
Can you indicate how you set?  Not all such setups allow "Reply to"
0
Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

 

Author Comment

by:lrbrister
ID: 41759345
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
 
LVL 95

Expert Comment

by:John Hurst
ID: 41759351
Thanks. When you insert a verifiable in replyToAddress = and run the code, what error do you get?
0
 

Author Comment

by:lrbrister
ID: 41759355
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
 
LVL 95

Expert Comment

by:John Hurst
ID: 41759358
Thanks. That was confusing for me to sort out from the screen print. So the function you want is not supported.
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 41759361
It would appear that the ReplyTo property in SendGrid expects an array of addresses, not a single address.
0
 

Author Comment

by:lrbrister
ID: 41759392
Shaun... how do I set that array?
0
 
LVL 36

Expert Comment

by:Kimputer
ID: 41759406
myMessage.ReplyToList.Add(replyToAddress)

So, remove whole ReplyTo line
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 41759409
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
 

Author Comment

by:lrbrister
ID: 41759419
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
 

Author Comment

by:lrbrister
ID: 41759763
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
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 41759833
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
 

Author Closing Comment

by:lrbrister
ID: 41759834
Bingo!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

689 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question