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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAPIMESSAGE sending problem

Status
Not open for further replies.

pcwc66

IS-IT--Management
Joined
Dec 14, 2001
Messages
163
Location
US
I'm using MAPIMESSAGE and MAPISESSION control. For some reasons, if I only send to 1 recipient, it won't work. If I send to more than 1 recipients, it is working fine.

the coding is like this:

loMAPISession.SignOn
loMAPIMessage.SessionID = loMAPISession.SessionID

*/ Start a new mail message and build the text
loMAPIMessage.Compose()
for lnCtr = 1 to alen(laRecipients, 1)
loMAPIMessage.RecipIndex = loMAPIMessage.RecipCount
loMAPIMessage.RecipType = laRecipients(lnCtr, 1)
loMAPIMessage.RecipDisplayName = laRecipients(lnCtr, 2)
endfor
loMAPIMessage.MsgSubject = lcSubject loMAPIMessage.MsgNoteText = lcBody
loMAPIMessage.Send(0)
loMAPISession.SignOff

Do I need to set any other properties?

Thank you for any help.
 
pcwc66

This works for me, I realise it is not using the OCX.
Code:
oSession = CreateObject("MAPI.Session")
oSession.Logon(&quot;Microsoft Outlook Internet Settings&quot;,<password>)
oNewMessage=oSession.Outbox.messages.add()
oNewMessage.Subject = &quot;This is an e-mail using CDO&quot;
oNewMessage.Text = &quot;Welcome to the world of CDO&quot;
oNewMessage.DeliveryReceipt = .T. &&Optional, forces a receipt send back
oRecipient = oNewMessage.Recipients.Add()
oRecipient.Name = &quot;John Doe&quot; && This name must appear in your address book.
oRecipient.Resolve && If name does not appear this will cause an error.
oNewMessage.Update()
oNewMessage.Send()
oSession.Logoff()


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi Mike,

If I comment out the coding

loMAPIMessage.RecipIndex = loMAPIMessage.RecipCount,

then I can send to 1 recipient. It seems that if the loMAPIMessage.RecipIndex is updated from 0 to 0, it won't work if only sending to 1 recipient.

Thank you for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top