Hi I want to send an email throwgh VB code. Please send a sample code. thanks
K kn_kirankumar Aug 5, 2004 #1 Hi I want to send an email throwgh VB code. Please send a sample code. thanks
O One Handed Man \( OHM - Terry Burns \) Aug 5, 2004 #2 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
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