Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,568 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,906 people online right now. Registration is fast and FREE... Join Now!




Sending an email through VB 08 EE

 
Reply to this topicStart new topic

Sending an email through VB 08 EE

The Rock
13 May, 2008 - 08:18 PM
Post #1

New D.I.C Head
*

Joined: 24 Sep, 2007
Posts: 16


My Contributions
Hello,

I am trying to figure out how to send an e-mail from my program with the contents of a richtextbox. For example: I am creating a notepad style program. And say I want to send what I wrote in the textbox via e-mail the short and quick way via the program. I want to be able to have the body of the email be the text that is written in the textbox on the main page. Here is the code. Any help would be greatly appreciated. Thanks.

CODE

    Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click
        Dim address As New System.Net.Mail.MailMessage(YourEmail.Text, SendTo.Text)
        address.Subject = Subject.Text
        address.Body = Notepad2.TextBox
        'If your email body contains Html tags then
        address.IsBodyHtml = False
        'Dim smtp As New System.Net.Mail.SmtpClient("ServerName", 25)
        'For eg for gmail you can give --
        Dim smtp As New System.Net.Mail.SmtpClient("smtp.gmail.com", 465)
        smtp.Send(address)
    End Sub


YourEmail.Text = Text box that the user inputs their email address
SendTo.Text = Text box that the user inputs the designation email
Subject.Text = Text box that the user includes a subject line for the email
Notepad2.TextBox = The contents in which the user write something in to be inputted as a body content (this is the part that i get confused and lost at. It is asking me that it cannot be converted into a 'string')

Thanks.

The Rock
User is offlineProfile CardPM
+Quote Post

The Rock
RE: Sending An Email Through VB 08 EE
13 May, 2008 - 10:50 PM
Post #2

New D.I.C Head
*

Joined: 24 Sep, 2007
Posts: 16


My Contributions
I figured out my problem with the coding. I needed a .text after the Notepad2.TextBox! Now I figured that part out. Now, in testing this problem out, my program freezes when I try to send the email. What am I doing wrong there? Thanks.

The Rock

This is my code as of now:

CODE

    Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click
        Dim address As New System.Net.Mail.MailMessage(YourEmail.Text, SendTo.Text)
        address.Subject = Subject.Text
        address.Body = Notepad2.TextBox.Text
        'If your email body contains Html tags then
        address.IsBodyHtml = False
        'Dim smtp As New System.Net.Mail.SmtpClient("ServerName", 25)
        'For eg for gmail you can give --
        Dim smtp As New System.Net.Mail.SmtpClient("smtp.gmail.com", 465)
        smtp.Send(address)
    End Sub


This post has been edited by The Rock: 13 May, 2008 - 10:51 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 11:54PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month