Results 1 to 6 of 6

Thread: How to send Emails

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Posts
    29

    Question How to send Emails

    I'm making a program with visual basic 2008 express edition that the user needs to enter his/her email address. I need a way of sending them an email containing nothing fancy just a subject and a body. I can send emails to google mail email address using the smpt but nobody else. I there a way to send an email to someone no matter what email domain they have. Also when this email is sent I need to send an email to me (Removed By Mod)

    How can I do this?
    Bye
    Last edited by Hack; Sep 1st, 2009 at 12:56 PM. Reason: Removed EMail Address

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: How to send Emails

    Did you search the forum? This question gets asked and answered a lot here.

  3. #3
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: How to send Emails

    Use the System.Net.Mail namespace. It has all the methods to create and send emails.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  4. #4

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to send Emails

    I have edited your post and removed your email address.

    You should never post your email address in an open post on an open forum. Mail spam bots can pick that up and before you know it, your mailbox is full of junk mail. If you wish to share your email address with other forum members, please do so via our PM system.

    In addition, we prefer all answers to questions be publically posted rather than sent via EMail or PM. That way, everyone with a similar problem can benefit.

    Thanks.

  6. #6
    Addicted Member
    Join Date
    Sep 2009
    Location
    The Netherlands
    Posts
    148

    Re: How to send Emails

    Hi,
    A few days ago I've made the same thing.
    This is the code I've used:
    vb.net Code:
    1. Imports System.Net.Mail
    2. Public Class Form1
    3.  
    4. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    5. Dim MyMailMessage As New MailMessage()
    6. Try
    7. MyMailMessage.From = New MailAddress("@@@")
    8. MyMailMessage.To.Add("@@@")
    9. MyMailMessage.Subject = "@@@"
    10. MyMailMessage.Body = "Name" & vbTab & ": " & Name.Text & vbNewLine
    11.  
    12. Dim SMTP As New SmtpClient("@@") 'put in you providers SMTP server
    13. SMTP.EnableSsl = False
    14. SMTP.Credentials = New System.Net.NetworkCredential("@@@", "@@@") '1st @@@ emailaddess 2nd @@@ password
    15. SMTP.Send(MyMailMessage)
    16. MessageBox.Show("Mail send", MsgBoxStyle.Information, "Information")
    17. Catch ex As Exception
    18. End Try
    Although (as far as I know) it depends on your providers SMTP and if they allow to send mails at port 25. My provider only let me send SMTP mail through their smtp address. So if you want to be able to send from different places be sure to adjust the SMTP address.

    Again, if i'm wrong, love to hear it.

    Paul
    Last edited by Hakka; Sep 3rd, 2009 at 06:51 AM. Reason: typo

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width