Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Create E-mail client in VB


Message #1 by "Sokun, Chorn" <sokunxp@g...> on Thu, 15 Nov 2001 21:08:04 +0700
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C17185.2924A120
Content-Type: text/plain;
	charset="iso-8859-1"

Create a new proj.  Create a new class and paste this code in.  Reference
cdonts.dll
 
 
'*******************************************************
'   SMTEMail Class.
'   This Class sends email through CDONTS.  It does not interface with MAPI
'   Created by fergalk 20/11/01
'   Dependencies: CDONTS.DLL
'   Changes:
'
'
'
'*******************************************************
 
Option Explicit
 
Public Body As String
Public Subject As String
Public FromEmail As String
Public FromName As String
Public RecipientEmail As String
Public MailFormat As Integer
 

Const smtEmail_ReturnCode_OK = 0
Const smtEmail_ReturnCode_Unspecified = -1
Const smtEmail_ReturnCode_Invalid_ToAddress = -2
Const smtEmail_ReturnCode_Malformed_EmailAddress = -3
Const smtEmail_ReturnCode_CDONTSError = -4
 
Private InternalErrorCode As Long
 

Public Function SendMail() As Long
 
On Error GoTo Handler
 
If RecipientEmail = "" Or InStr(1, RecipientEmail, "@", vbTextCompare) = 0
Then Err.Raise -2
 

Dim objCDOEmail As CDONTS.NewMail
Set objCDOEmail = New CDONTS.NewMail
 
With objCDOEmail
    
    .Body = Body
    .Subject = Subject
    .From = FromEmail
    .BodyFormat = MailFormat
    .To = RecipientEmail
    .Send
    
End With
 
 
 

'Return Zero to indicate success
SendMail = smtEmail_ReturnCode_OK
Set objCDOEmail = Nothing
Exit Function
 
Handler:
 
Select Case Err.Number
 
    Case -2
        SendMail = Err.Number
    Case Else
        SendMail = smtEmail_ReturnCode_Unspecified
    
End Select
 
Set objCDOEmail = Nothing
 
End Function
 
Private Sub Class_Initialize()
'Needs to be initialised
MailFormat = 0
End Sub


-----Original Message-----
From: Sokun, Chorn [mailto:sokunxp@g...]
Sent: Friday, 16 November 2001 01:08 AM
To: professional vb
Subject: [pro_vb] Create E-mail client in VB


Does any body knew how to write a simple e-mail client just be able to send
out e-mail.

I am just have no idea to start. Please help ---




  Return to Index