VB help

K

kn_kirankumar

Hi

I want to send an email throwgh VB code.
Please send a sample code.

thanks
 
O

One Handed Man \( OHM - Terry Burns \)

Dim mailmsg As New MailMessage() '//Ensure u have imported System.web.mail

With mailmsg

..From = Me.txtFrom.Text.Trim()

..To = Me.txtTo.Text.Trim()

..Cc = Me.txtCC.Text.Trim()

..Bcc = Me.txtBCC.Text.Trim()

..Subject = Me.txtSubject.Text.Trim()

..Body = Me.txtBody.Text.Trim()

Select Case Me.cboPriority.SelectedIndex

Case 0

..Priority = MailPriority.Low

Case 1

..Priority = MailPriority.Normal

Case 2

..Priority = MailPriority.High

End Select

Dim s As String

For Each s In Me.lstAttachments.Items

..Attachments.Add(New MailAttachment(s))

Next s

End With

Try

SmtpMail.Send(mailmsg)

MessageBox.Show("Your mail has been successfully sent!")

Catch ex As Exception

MessageBox.Show("The following problem occurred when attempting to send your
mail: " & ex.Message)

End Try

End Sub


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top