Click to See Complete Forum and Search --> : MAPI components -Urgent !!


richardlctan
March 28th, 2001, 01:58 AM
Pls help me out of this send-email issue.

Program stop at executing the line --
---Messages1.ResolveName
An error msg prompt out-" unknown recipient ".

======================================
Private Sub SendMail(pintMailMode As Integer, Optional intWmsorMax As Integer)
Dim intPlOrPk As Integer
'On Error Resume Next

MAPISession1.LogonUI = False
MAPISession1.UserName = "XXXXXXXXX"
MAPISession1.Password = "XXXXXX"
MAPISession1.SignOn
If Err.Number <> 0 Then
MsgBox "Invalid signon attempt,please try agian "
Exit Sub
End If
MAPIMessages1.SessionID = MAPISession1.SessionID
MAPIMessages1.MsgIndex = -1
MAPIMessages1.Compose
MAPIMessages1.MsgSubject = " Daily Intigrity Checking"
MAPIMessages1.MsgNoteText = " "
MAPIMessages1.AttachmentName ="win"
MAPIMessages1.AttachmentPathName ="c:\windows\win.ini"
MAPIMessages1.AttachmentType = mapData
MAPIMessages1.RecipDisplayName = "PENTRAC - Tan, Lye Chuan"
MAPIMessages1.RecipAddress= "lyechuantan@pg.slr.com"
MAPIMessages1.ResolveName

MAPIMessages1.Send False
MAPISession1.SignOff
ProcExit:
Exit Sub
ProcError:
msgbox Err.Description
End Sub

Iouri
March 28th, 2001, 07:15 AM
Try this code. It works

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
'if True then open Netscape and wait, if false then sends to Eudora.
.Send False
End With
End Sub



Iouri Boutchkine
iouri@hotsheet.com