Click to See Complete Forum and Search --> : generating emails


harshal_mankodi
August 28th, 2001, 12:39 AM
hi i wanted to inquire abt as to hot to generate e mails using vb6.0

Iouri
August 28th, 2001, 06:52 AM
'make sure that on the default e-mail use of MAPI server is allowed

Option Explicit
'2 controls Microsoft MAPI Control 6.0 -> MAPISession and MAPIMessages

Private Sub Command1_Click()
Dim msg As String

Screen.MousePointer = vbHourglass

msg = "This is a test email"

With Me

.MAPILogOn.SignOn ' use current user

Do While .MAPILogOn.SessionID = 0
DoEvents ' need to wait until the new session is created
Loop

Call SendToEmail("iboutchkine@hotmail.com", msg)

.MAPILogOn.SignOff
End With

Screen.MousePointer = vbNormal

End Sub

Private Sub SendToEmail(ByVal Email As String, ByVal msg As String)
With MAPIMessages1
'create a new message and address it
.SessionID = MAPILogOn.SessionID
.Compose
.RecipDisplayName = Email
.AddressResolveUI = True
.RecipAddress = "smtp:" & Email

.MsgSubject = "VB GENERATED E-MAIL"
.MsgNoteText = msg
.Send False
End With
End Sub



Iouri Boutchkine
iouri@hotsheet.com