Solved

smtp replyto MailAddress

Posted on 2016-08-17
15
37 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 90

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 90

Expert Comment

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

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 90

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 90

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 25

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 25

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 25

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Encryption Decryption in Oracle 12 59
VB.net PaintEventArgs Handling. 10 27
Exception in Log4Net 1 18
Limiting string to two deciamls 18 32
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now