locked
How do I add an email to a program? RRS feed

  • Question

  • I simply want to allow the user to send info to my email address via the distributed program. They enter the info into the textbox and hit the send button and then I want to recieive that at my email. Any idears?

    Thanx

    B

     


    Brenton W Garman
    Monday, July 19, 2010 5:07 PM

Answers

  • That's what I've been referring to in all of my replies; unless you plan on running your own mail server, you're probably better off just getting a mail account with some email provider i.e. gmail, yahoo, the company that you're working for (if applicable).  You would then set the destination address to be that companies email server.

    As I've said, search engines are your friend; there are lots of examples.  Here's one that I've pulled off of another MSDN forum:

    SmtpClient dd = new SmtpClient("smtp.gmail.com", 25);
    dd.EnableSsl = true;
    dd.Credentials = new System.Net.NetworkCredential(@"your mail ID", "Your mail password");
    dd.Send("sender's mail address", "Receiver's mail address", "Subject", "Matter");

    • Proposed as answer by Max Will Monday, July 19, 2010 8:30 PM
    • Marked as answer by Liliane Teng Monday, July 26, 2010 7:09 AM
    Monday, July 19, 2010 7:47 PM
  • This works perfect with Gmail.

    Imports System.Net.Mail
    Public Class Form1
    
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Dim message As New MailMessage
      Dim smtp As New SmtpClient
      message.To.Add("email address" Or TextBox.Text)
      message.From = New MailAddress("from email address", "name of email addresses owner")
      message.Subject = "subject" Or TextBox.Text
    message.Body = "message" Or TextBox.Text smtp.Host = "smtp.gmail.com" smtp.Port = "587" smtp.EnableSsl = True smtp.Credentials = New Net.NetworkCredential("username", "password") smtp.Send(message) End Sub End Class

    Monday, July 19, 2010 8:58 PM
    • Marked as answer by Liliane Teng Monday, July 26, 2010 7:10 AM
    Monday, July 19, 2010 9:16 PM
  • The problem was that your username/password was incorrect.

    Do you have an account, and are you using the right username/password?

    • Marked as answer by Liliane Teng Monday, July 26, 2010 7:10 AM
    Tuesday, July 20, 2010 1:32 PM
  • sometimes gmail's usernames could be your username@gmail.com.

    Imports System.Net.Mail
    Public Class Form1
    
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     Dim message As New MailMessage
     Dim smtp As New SmtpClient
     message.To.Add("email address" Or TextBox.Text)
     message.From = New MailAddress("from email address", "name of email addresses owner")
     message.Subject = "subject" Or TextBox.Text
    message.Body = "message" Or TextBox.Text smtp.Host = "smtp.gmail.com" smtp.Port = "587" smtp.EnableSsl = True smtp.Credentials = New Net.NetworkCredential("username@gmail.com", "password") smtp.Send(message) End Sub End Class

    Tuesday, July 20, 2010 1:56 PM

All replies

  • What email do you want the program to send it from?  Are you planning on making your own email address just for the program that it can use?  Are you planning on having users use their own email address?

    The SmtpClient Class is what you can use to send simple emails.  Searching this forum or google (and also looking through that link) can show you several code examples.

    Monday, July 19, 2010 6:25 PM
  • System.Net.Mail....  

    Tom Shelton
    Monday, July 19, 2010 6:35 PM
  • yeah, I just want to allow the user to enter info , click send and the info arrives at my email embedded in the code of the program.
    Brenton W Garman
    Monday, July 19, 2010 6:57 PM
  • This website is the website for everything you always wanted to know about System Net Mail

    http://www.systemnetmail.com/


    Success
    Cor
    Monday, July 19, 2010 7:01 PM
  • yeah, I just want to allow the user to enter info , click send and the info arrives at my email embedded in the code of the program.
    Brenton W Garman

    I've been in that situation myself and I just went and created a new gmail account for the program and had it send the data using that account.  You can use whatever mail you want, but I would highly suggest getting a new email specifically for this program rather than using one that is also used elsewhere.
    Monday, July 19, 2010 7:18 PM
  • I have gotten this far....

    <

     

    'create the mail message

     

    Dim mail As New MailMessage()

     

    'set the addresses

     

    'mail.From = New MailAddress("me@mycompany.com")

    mail.To.Add(

    "gs@garmanstrings.com")

     

    'set the content

    mail.Subject =

    "Torrent Site Suggestion"

    mail.Body =

    Me.TextBox1.Text

     

    'send the message

     

    Dim smtp As New SmtpClient("127.0.0.1")

    smtp.Send(mail)/>

    Question: What email do I put for the 'mail.From = New MailAddress(me@mycompany.com)?

    Thanx


    Brenton W Garman
    Monday, July 19, 2010 7:38 PM
  • That's what I've been referring to in all of my replies; unless you plan on running your own mail server, you're probably better off just getting a mail account with some email provider i.e. gmail, yahoo, the company that you're working for (if applicable).  You would then set the destination address to be that companies email server.

    As I've said, search engines are your friend; there are lots of examples.  Here's one that I've pulled off of another MSDN forum:

    SmtpClient dd = new SmtpClient("smtp.gmail.com", 25);
    dd.EnableSsl = true;
    dd.Credentials = new System.Net.NetworkCredential(@"your mail ID", "Your mail password");
    dd.Send("sender's mail address", "Receiver's mail address", "Subject", "Matter");

    • Proposed as answer by Max Will Monday, July 19, 2010 8:30 PM
    • Marked as answer by Liliane Teng Monday, July 26, 2010 7:09 AM
    Monday, July 19, 2010 7:47 PM
  • SmtpClient dd = new SmtpClient("smtp.gmail.com", 25);


    While everything looks good with your code example above, I do believe that Gmail uses port 587 for their SMTP service.
    Monday, July 19, 2010 8:31 PM
  • This works perfect with Gmail.

    Imports System.Net.Mail
    Public Class Form1
    
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Dim message As New MailMessage
      Dim smtp As New SmtpClient
      message.To.Add("email address" Or TextBox.Text)
      message.From = New MailAddress("from email address", "name of email addresses owner")
      message.Subject = "subject" Or TextBox.Text
    message.Body = "message" Or TextBox.Text smtp.Host = "smtp.gmail.com" smtp.Port = "587" smtp.EnableSsl = True smtp.Credentials = New Net.NetworkCredential("username", "password") smtp.Send(message) End Sub End Class

    Monday, July 19, 2010 8:58 PM
    • Marked as answer by Liliane Teng Monday, July 26, 2010 7:10 AM
    Monday, July 19, 2010 9:16 PM
  • getting the following error message when i run the app and hit send where the code is within:

    "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required."

    help?


    Brenton W Garman
    Tuesday, July 20, 2010 3:49 AM
  • getting the following error message when i run the app and hit send where the code is within:

    "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required."

    help?


    Brenton W Garman

    Did you try this?

    Imports System.Net.Mail
    Public Class Form1
    
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     Dim message As New MailMessage
     Dim smtp As New SmtpClient
     message.To.Add("email address" Or TextBox.Text)
     message.From = New MailAddress("from email address", "name of email addresses owner")
     message.Subject = "subject" Or TextBox.Text
    message.Body = "message" Or TextBox.Text smtp.Host = "smtp.gmail.com" smtp.Port = "587" smtp.EnableSsl = True smtp.Credentials = New Net.NetworkCredential("username", "password") smtp.Send(message) End Sub End Class

    Tuesday, July 20, 2010 4:22 AM
  • yes and same error message...so frustrating

    thankx for your help thou

    b


    Brenton W Garman
    Tuesday, July 20, 2010 4:29 AM
  • The problem was that your username/password was incorrect.

    Do you have an account, and are you using the right username/password?

    • Marked as answer by Liliane Teng Monday, July 26, 2010 7:10 AM
    Tuesday, July 20, 2010 1:32 PM
  • sometimes gmail's usernames could be your username@gmail.com.

    Imports System.Net.Mail
    Public Class Form1
    
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     Dim message As New MailMessage
     Dim smtp As New SmtpClient
     message.To.Add("email address" Or TextBox.Text)
     message.From = New MailAddress("from email address", "name of email addresses owner")
     message.Subject = "subject" Or TextBox.Text
    message.Body = "message" Or TextBox.Text smtp.Host = "smtp.gmail.com" smtp.Port = "587" smtp.EnableSsl = True smtp.Credentials = New Net.NetworkCredential("username@gmail.com", "password") smtp.Send(message) End Sub End Class

    Tuesday, July 20, 2010 1:56 PM