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
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