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

Sending email using MAPI controls through a VFP6 app. 2

Status
Not open for further replies.

VFP6

Programmer
Jan 2, 2001
6
US
Dear Whoever can help,
I am trying to send emails based on a certain condition in a program. One problem I am having is sending emails to more than one recipient in a single send. The other problem I am having is sending Cc: Mail. Below is a sample of the code that I have written. At first, I had the FOR LOOP contained in the calling procedure so it would logon, send out an email, and logoff before sending email to the next recipient. I moved the LOOP to inside the code to save time and test whether all the addresses could be added to the To: box and sent at one time. This was an unsuccessful test. If anyone knows what needs to be done to accomplish this goal I would greatly appreciate the help. Thanks in advance, Anthony





PROCEDURE SendMail
LOCAL loSession, loMessage
tcSubject = "PLEASE HELP!"
tcText = "THANKS!"
mail1 = "address@yahoo.com"
mail2 = "address@excite.com"
mail3 = "address@aol.com"
mail4 = "address@hotmail.com"
oSession = CREATEOBJECT("MSMapi.MapiSession")
loMessage = CREATEOBJECT("MSMapi.MapiMessages")
loSession.LogonUI = .T.
loSession.DownLoadMail = .F.
loSession.NewSession = .T.
loSession.UserName = 'Microsoft Outlook'
loSession.PASSWORD = ''
loSession.Signon
loMessage.sessionid = loSession.sessionid
loMessage.MsgIndex = -1
loMessage.Compose
FOR i = 1 TO 4
mail = "mail" + ALLTRIM(STR(i))
tcRecipient = &mail
loMessage.RecipAddress = ALLTRIM(tcRecipient)
loMessage.ResolveName
ENDFOR
loMessage.MsgSubject = IIF(NOT EMPTY(tcSubject), tcSubject, "")
loMessage.MsgNoteText = IIF(NOT EMPTY(tcText), tcText, "")
loMessage.SEND
loSession.signoff
WAIT CLEAR
RETURN .T.
ENDPROC
 
Hi Anthony,

FOR i = 1 TO 4
mail = "mail" + ALLTRIM(STR(i))
tcRecipient = &mail
loMessage.RecipIndex=i-1
IF i > 1
loMessage.RecipType = 2 && 2 = CC, 3 = BCC
ENDIF

loMessage.RecipAddress = ALLTRIM(tcRecipient)
loMessage.ResolveName
ENDFOR

Refer the RecipIndex & RecipType properties in the MAPI controls help file for more information.
Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Hey Jon,

I have added your code to mine and tested it already.

Thank you,
~~Anthony
awdigrigoli@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top