Solved

smtp replyto MailAddress

Posted on 2016-08-17
15
53 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
  • 7
  • 4
  • 3
  • +1
15 Comments
 
LVL 93

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 93

Expert Comment

by:John Hurst
ID: 41759339
Can you indicate how you set?  Not all such setups allow "Reply to"
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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 93

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 93

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 35

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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