Send email throught VB.NET 2005

M

Mike TI

April 12, 2006

Hi all

I want to send an email through a VB.Net 2005 application. Can someone show
me some examples:

1. To send an email through the current default email client, Outlook
Express or Microsoft Office Outlook.
2. Can you determine which is the default client in the application.
3. Send an email that does not use any default email client.

Thank you.
 
T

tomfri

Here is a class doing the job connecting directly to the mailserver,
not by me. Found it somewhere on the web

So this uses no defoult client

* add the System.Web.Dll reference to your .Net
'* project if doing a Windows Application. An
'* ASP.Net app should include this reference.
'* Simply declare an object of type SendMail in code, ie another class
like a form class,
'* set the body and subject properties, then call
'* MailMessage to send the email
Imports System.Web.Mail



Public Class SendMail
Private _Subject As String
Private _Body As String
Private _Attachment As String
Private _Adress As String
Public Property Adress() As String
Get
Return _Adress
End Get
Set(ByVal Value As String)
_Adress = Value
End Set
End Property
Public Property Subject() As String
Get
Return _Subject
End Get
Set(ByVal Value As String)
_Subject = Value
End Set
End Property
Public Property Body() As String
Get
Return _Body
End Get
Set(ByVal Value As String)
_Body = Value
End Set
End Property
Public Property Attachment() As String
Get
Return _Attachment
End Get
Set(ByVal Value As String)
_Attachment = Value
End Set
End Property
Public Sub MailMessage()
Dim objMail As New MailMessage
'Dim attach As New MailAttachment(_Attachment)
SmtpMail.SmtpServer = "000.00.00" 'this needs to be the Smtp
mail server, a proxy will not work, get this from your administrator,
or Exchange server name in outlook
objMail.From = "sender@home"
objMail.To = _Adress
objMail.Subject = _Subject 'Subject text
objMail.Body = _Body 'Body Text
objMail.BodyFormat = MailFormat.Text 'Html 'can be text also
SmtpMail.Send(objMail)
End Sub
End Class
 

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