Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about SMTP

Status
Not open for further replies.

Everton1Blue

Technical User
Jun 6, 2014
41
GB
Hello

My SMTP code includes:

Code:
 Dim strEmailValue As String
 Dim Message As String = "yourmessage"

 'Request.Form - extract data from form field

 Dim youremail As String = Request.Form("strEmailValue")
 Dim yourmessage As String = Request.Form("your_message")

.........

 myMessage.ReplyToList.Add(youremail) 'user's email
 myMessage.Body = yourmessage

I actually get an error with this line:
Code:
myMessage.ReplyToList.Add(youremail) 'user's email

but that is not the purpose of this question.

The Web page asks the user, who has forgotten his password, for his email address only. There is no message field, so aren't the above references to 'message' redundant? On the other hand, if there is no 'message', as in

Code:
 myMessage.Body = yourmessage

how is the user to receive the link sent to him to reset his password?

Many thanks.
 
what is myMessage? It must be a class an object you defined somewhere.
 
Try something like this.

Grab you form data (the email address they send you) and stic it in the msg.body

Dim emailrecipient As String = ("whoyousendigitto@whereever.com")
Dim smptclient As SmtpClient = New SmtpClient()
Dim mmsg As MailMessage = New MailMessage()
mmsg.From = New MailAddress("thesending emailaccount@sender.com")
mmsg.To.Add(New MailAddress(emailrecipient))
mmsg.Subject = ("put your subject line here")
mmsg.Body = ("Put the link you want them to clck on here wiwth any messages")
mmsg.IsBodyHtml = True

Dim basicAuthenticationInfo As New NetworkCredential("username", "pwd")
smptclient.Host = ("localhost")
smptclient.UseDefaultCredentials = (False)
smptclient.Credentials = basicAuthenticationInfo


Try
smptclient.Send(mmsg)
Catch objSmtpException As SmtpException

'put your error handling here

End Try
 
Hello jBenson001

Thank you for your reply.

myMessage looks like this:

Code:
Dim myMessage As New MailMessage
            Dim Smtpserver As New SmtpClient
            Dim strEmailValue As String
            Dim Message As String = "yourmessage"

            'Request.Form - extract data from form field

            Dim youremail As String = Request.Form("strEmailValue")
            Dim yourmessage As String = Request.Form("your_message")

            'create the mail message

            myMessage.From = New MailAddress("info@mySite.net") 'Webmaster's email
            myMessage.To.Add(New MailAddress("info@mySite.net")) 'recipient at same company
            myMessage.ReplyToList.Add(youremail) 'user's email
            myMessage.Body = yourmessage
            myMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
            myMessage.IsBodyHtml = True
            myMessage.Priority = MailPriority.High

Thanks again.

Blue
 
Hello Dashley

Thanks for your message.

I will try the code you kindly posted a little later today and post back soon!

Thanks again.

Blue
 
Hello Dashley

I haven't tried this out yet (I have had to adapt your code a little to the syntax I was using), but I think I have tidied up the
confusion with Webmaster email and user email), so I now have:

Code:
Dim myMessage As New MailMessage
Dim Smtpserver As New SmtpClient
Dim strEmailValue As String
Dim Message As String = "resetLink"

Dim emailrecipient As String = Request.Form("strEmailValue")

Dim resetLink As String = Request.Form("myMessage")

'create the mail message

myMessage.From = New MailAddress("webmasterEmail@whatever.net") 'Webmaster's email
myMessage.To.Add(New MailAddress("emailrecipient")) 'User's email
            
'myMessage.ReplyToList.Add(youremail) 'user's email <----Comment out ReplyToList line            

myMessage.Subject = ("Password Reset Request")

myMessage.Body = resetLink

Try

Smtpserver.Send(myMessage)

Catch SmtpException as SmtpException

'Error handling here

End Try

But I am not sure about the following lines:

Code:
Dim Message As String = "resetLink"
Dim resetLink As String = myMessage (but there is no form field for myMessage with an ID of resetLink)
myMessage.Body = resetLink

Please let me know!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top