Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAPI E-mail VB question

Status
Not open for further replies.

wrbodine

Programmer
Aug 24, 2000
302
US
I'm using the MSMapi.MapiMessages object to open an e-mail message to a specified person. The following 2 lines of code enable the name entered to be resolved in Outlook:

message.AddressResolveUI = True
message.ResolveName

If the name isn't in the address book, a message is brought up for them to resolve the name. My question is, how can I know in my VB Code whether this occured or not (whether they were prompted to resolve the name)?

TIA,
Ray
 
wrbodine,

I need to incorporate e-mail capability in my vb6 app. If you have a 'working' model, i would very much appreciate any info you can share, up to and including any classes/module/code which encapsulate the function.

TIA


MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
(if anyone knows the answer to the first question it would be greatly appreciated!!)

MichaelRed,

Here's e-mail code for use within a VB6 form that I've been using...

Dim sNote$, Reciever$
Dim sqlstr$
Dim rs As New ADODB.Recordset

sNote = "Message to put in e-mail. " & String(100, " ")
sNote = sNote & "Second line of message" & Variable & String(100, " ")

sqlstr = "SELECT EMail, FName, LName FROM tblEmployees WHERE UserName = '" & txtUser.Text & "'"

rs.Open sqlstr, Conn, adOpenForwardOnly, adLockReadOnly

If Not IsNull(rs!EMail) Then
sReciever = rs!EMail & "@MyCompany.com"
else
sReciever = rs!LName & ", " & rs!fName
End if

rs.Close
Set rs = Nothing

'initiates email message
On Error Resume Next
If sReciever <> &quot;&quot; Then
session.SignOn

message.SessionID = session.SessionID
message.Compose

message.RecipDisplayName = sReciever
message.AddressResolveUI = True
message.ResolveName

message.MsgSubject = &quot;Subject title for e-mail&quot;
message.MsgNoteText = sNote
message.Send True

session.SignOff
End If
 
???????????????

Sub Command1_Click()
'MAPI constants from CONSTANT.TXT file:
Const SESSION_SIGNON = 1
Const MESSAGE_COMPOSE = 6
Const ATTACHTYPE_DATA = 0
Const RECIPTYPE_TO = 1
Const RECIPTYPE_CC = 2
Const MESSAGE_RESOLVENAME = 13
Const MESSAGE_SEND = 3
Const SESSION_SIGNOFF = 2

'Open up a MAPI session:
MAPISession1.Action = SESSION_SIGNON
'Point the MAPI messages control to the open MAPI session:
MAPIMessages1.SessionID = Form1.MAPISession1.SessionID

MAPIMessages1.Action = MESSAGE_COMPOSE 'Start a new message

'Set the subject of the message:
MAPIMessages1.MsgSubject = &quot;This is the subject.&quot;
'Set the message content:
MAPIMessages1.MsgNoteText = &quot;This is the mail message.&quot;

'The following four lines of code add an attachment to the message,
'and set the character position within the MsgNoteText where the
'attachment icon will appear. A value of 0 means the attachment will
'replace the first character in the MsgNoteText. You must have at
'least one character in the MsgNoteText to be able to attach a file.
MAPIMessages1.AttachmentPosition = 0
'Set the type of attachment:
MAPIMessages1.AttachmentType = ATTACHTYPE_DATA
'Set the icon title of attachment:
MAPIMessages1.AttachmentName = &quot;System Configuration File&quot;
'Set the path and file name of the attachment:
MAPIMessages1.AttachmentPathName = &quot;C:\CONFIG.SYS&quot;

'Set the recipients
MAPIMessages1.RecipIndex = 0 'First recipient
MAPIMessages1.RecipType = RECIPTYPE_TO 'Recipient in TO line
MAPIMessages1.RecipDisplayName = &quot;EddieSpaghetti&quot; 'e-mail name
MAPIMessages1.RecipIndex = 1 'add a second recipient
MAPIMessages1.RecipType = RECIPTYPE_TO 'Recipient in TO line
MAPIMessages1.RecipDisplayName = &quot;TanyaLasagna&quot; 'e-mail name
MAPIMessages1.RecipIndex = 2 'Add a third recipient
MAPIMessages1.RecipType = RECIPTYPE_CC 'Recipient in CC line
MAPIMessages1.RecipDisplayName = &quot;BlairAngelHair&quot; 'e-mail name
MAPIMessages1.RecipIndex = 3 'Add a fourth recipient
MAPIMessages1.RecipType = RECIPTYPE_CC 'Recipient on CC Line
MAPIMessages1.RecipDisplayName = &quot;JoanieCannelloni&quot; 'e-mail name&quot;

'MESSAGE_RESOLVENAME checks to ensure the recipient is valid and puts
'the recipient address in MapiMessages1.RecipAddress
'If the E-Mail name is not valid, a trappable error will occur.
MAPIMessages1.Action = MESSAGE_RESOLVENAME
'Send the message:
MAPIMessages1.Action = MESSAGE_SEND

'Close MAPI mail session:
MAPISession1.Action = SESSION_SIGNOFF
End Sub


Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX.

Download Demo version on my Site:
Promotions before 02/28/2001 (free source codebook),visite my site
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top