Hi all,

Thanks for the support u have given till now.I had a confusion in sending email like

I have created a button for email and i want to send the text which is in a textbox iam using " Me.mapiSession.SignOn() " code for sending but i have missed some thing its not working. Can u help please. iam using .NET 2005 for this code.
System : windows XP serice pack 2
IIS Installed On my system

Hope a soon reply.
Thanks and regards

You can try this code:::


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim message As New MailMessage(txtTo.Text, txtFrom.Text, txtSubject.Text, txtBody.Text)

If txtFrom.Text.Trim() = "" Then
MessageBox.Show("Enter the From address.", "Email Error", MessageBoxButtons.OK, _
MessageBoxIcon.Stop)
txtFrom.Focus()
Exit Sub
End If

If txtTo.Text = "" Then
MessageBox.Show("Enter the Recipient address(es).", "Email Error", _
MessageBoxButtons.OK, MessageBoxIcon.Stop)
txtTo.Focus()
Exit Sub
End If

If txtSubject.Text = "" Then
MessageBox.Show("Enter the subject.", "Email Error", MessageBoxButtons.OK, _
MessageBoxIcon.Stop)
txtSubject.Focus()
Exit Sub
End If

Try

Dim emailClient As New SmtpClient(lblHost.Text)
Dim attachFile As New Attachment("k:\doc\DOCUMENTATION.doc")
'Dim attachFile As New Attachment(lstAttachment.Text)
message.Attachments.Add(attachFile)
emailClient.Send(message)
litStatus.Text = "Message Sent"

Catch ex As Exception
litStatus.Text = ex.ToString()
End Try
End Sub

This article has been dead for over six months. Start a new discussion instead.