First, here is the code I am using:
- Code: Select all Expand view
Function CDOSendMail( aTabMail )
Local oEmailCfg,oEmailMsg
/* Tabmail
01 = MAILSERVER // A correct mail server address
02 = MAILFROM // A valid originator of the message
03 = MAILTO // Who it is being sent to
04 = SUBJECT // The subect
05 = BODY // The body in text format
06 = ATTACHMENT // Attachment(s)
07 = BCC // Usually NIL NOT USED
08 = LAUTHORIZATION // T or F logical for authentication
09 = USERID pour MAILSERVER // The mail server Username
10 = PW pour MAILSERVER // The mail server password
11 = Mail port defaut = 25 // The port, default is 25, set to 465 for SSL
12 = Mail HTML page // An HTML page, usually not used
13 = ssl authentification // T or F logical for SSL
14 = Mail sender // Mail sender name NOT USED
15 = Organisation sender // Organization sender NOT USED
16 = Host // Host if needed NOT USED
*/
TRY
oEmailCfg := CREATEOBJECT( "CDO.Configuration" )
WITH OBJECT oEmailCfg:Fields
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := TRIM( aTabMail[01] ) //"mail.xxxxxxxx.com"
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := aTabMail[11] // 25
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2 // Remote SMTP = 2, local = 1
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := aTabMail[08] // .T.
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := aTabMail[13]
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value := TRIM( aTabMail[09] ) // "xxanser@xxxxxxxx.com"
:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := TRIM( aTabMail[10] ) // "xxxxxx"
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 30
:Update()
END WITH
CATCH oError
MsgInfo( "Could not create message configuration" + ";" + ;
"Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + ;
"SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + ;
"OSCode: " + TRANSFORM(oError:OsCode, NIL) + ";" + ;
"SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" + ;
"Message: " + oError:Description )
Return .F.
END
oError:=NIL
TRY
oEmailMsg := CREATEOBJECT ( "CDO.Message" )
WITH OBJECT oEmailMsg
:Configuration = oEmailCfg
:From = aTabMail[02] //chr(34)+" Anser K.K. "+chr(34)+ "<anser@xxxxxxxx.com>" // This will be displayed in the From (The email id does not appear)
:To = TRIM( aTabMail[03] ) // "xxanserkk@xxxxx.com" // <----- Place the TO email address
:Subject = aTabMail[04] // "This is a Tst message"
:MDNRequested = .T.
:TextBody = TRIM( aTabMail[05] )
IF LEN( aTabMail[06] ) > 0
For nEle := 1 To Len( aTabMail[06] )
:AddAttachment( ALLTRIM(aTabMail[06][nEle] )) // := AllTrim( aAttach[ nEle ] )
Next
ENDIF
END WITH
oEmailMsg:Send( )
CATCH oError
MsgInfo( "Could not send message" + ";" + CRLF+ ;
"Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + CRLF+;
"SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + CRLF+ ;
"OSCode: " + TRANSFORM(oError:OsCode, NIL) + ";" + CRLF +;
"SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" +CRLF+ ;
"Message: " + oError:Description )
Return .F.
END
Return( .t. )
On my computer this works. However, on a client's computer ( and other client's also ), I get the following response to the send() action:
Could not send message
Error 1001
SubC 3
OSCode 0
SubSystem CDO_Message;
Message DISP_E_MEMBERNOTFOUND
I've run out of ideas on what might be causing the problem on some computers. Of course my clients think its something that I should fix in 2 minutes ! By the number of posts I've shown on this problem, its obvious I've spent a lot of time.
Also of note. I am using Windows 8 and it works. The machine I tested on this morning at a client's office is the same computer ( Samsung All In One, same model ) also with Windows 8.
Tim