Dear Mr.Michel,
Here is the sample code.
- Code: Select all Expand view
// Set up Email Configurations like SMTP, SMTP Port, UserID, Password Etc.oEmailCfg := CREATEOBJECT
( "CDO.Configuration" )WITH OBJECT oEmailCfg:
Fields :
Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):
Value :=
"smtp.gmail.com" :
Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):
Value :=
465 :
Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):
Value :=
2 // Remote=2, local=1 :
Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):
Value := .T.
:
Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):
Value := .T.
:
Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):
Value := cSendMailId
// ans@gmail.com :
Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):
Value := cSendMailIdPass
// Pass :
Update()END WITH
// Create Email Message with To,Bcc,CC, Subject, Attachments, Email Message Content,// Inline Pictures if any etc. and then Send the MessageoEmailMsg := CREATEOBJECT
( "CDO.Message" )WITH OBJECT oEmailMsg
:
Configuration = oEmailCfg
// Mail Config. Object :
From = chr
(34)+
" "+cFromName+
" "+chr
(34)+
"<"+cFromID+
">" // Disp in the From Col :
To = cToEmailId
// To email address :
Subject = cSubject
// Subject of the Email Message :
ReplyTo = cReplyId
// If specified, then Reply mail is send to this ID :
Sender = oMailer:
cAcknowId // Read Receipt message is send to this :
Organization = oMailer:
cFromName // "Anser's " If !empty
(cAttachment
) // Attachements if any :
AddAttachment(oMailer:
cAttachment) // For Eg "c:\LCd Projector.txt" Endif :
MDNRequested = .T.
// Request Read Receipt IF !empty
(cInlineAttachment
) // Inline Pic Attachement to the Body of the msg :
AddRelatedBodyPart("E:\Apps\Mailer\Files\Error.Jpg",
"Error.jpg",
0) Endif :
HTMLBody = cHtml
// cHtml contains the HTML Code contents and NOT the HTML File :
Send()END WITH
Mr. Micheal the above code is working fine here.
I am getting wierd results when I try to send it using a timer (repeated sending) For eg. sending 10 email messages in a minute, especially when the size of the email message is bigger than 200KB. I have 1000's of email address in an excel file and I want to send 12 or 20 or n number of email messages in a minute. Once the email messages are send; each record in the Excel file will be updated with the Send Date and Time.
I think the Timer action is activated even before the send activity of the previous timer action is finished. I will have to figure it out.
It works only when the Timer Action is called for the first time, the second time the app hangs.
I even used MsgRun to call the :Send(), so that the activities get paused till I finish the Send(), unfortunately not getting the expected result. I assume the next Timer Action get's fired even before the Send() is finished and FWH events are not getting fired as per the sequence expected by me
- Code: Select all Expand view
MsgRun("Sending Email from row "+str(nRow,6),"Please wait", { || oEmailMsg:Send() } )
Regards
Anser