Re: Send email throught VB.NET 2005

Tech-Archive recommends: Fix windows errors by optimizing your registry



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

.



Relevant Pages

  • Re: Getting Windows Display Name
    ... Private Type WKSTA_USER_INFO_1 ... usri3_script_path As Long 'Pointer to a Unicode string specifying the path for the user's logon script file. ... Dim bufptr As Long ... Public Property Get PasswordAgeAs Long ...
    (microsoft.public.access.modulesdaovba)
  • Private Class Variables Visible in Object Explorer
    ... All 3 objects' module level private ... Private strDestPath As String ... Public Property Let SetID(ByVal vNewValue As Date) ...
    (microsoft.public.access.modulesdaovba)
  • Re: common dialog w/api instead of COMDLG32.OCX, possible?
    ... As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As ... Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias ... Public Property Get FileNameAs String ...
    (microsoft.public.vb.winapi)
  • Re: XmlSerializer instantiation error
    ... > Private mLayerName As String ... > Private mUserDefined As Boolean ... > Public Property NumberOfBreaks() As Integer ...
    (microsoft.public.dotnet.xml)
  • Re: Class confusion
    ... Private mstrMyInfo1 As String ... Public Property Set MyShape ... Dim objNewMember As MyRect ...
    (microsoft.public.excel.programming)