brandelh hat geschrieben:wenn ich mich nicht irre untestützt Xbase++ kein IDispatch Interface,
es ist genau anders herum
Xbase++ und VB unterstützen IDispatch jedoch nicht IUnknown. Deshalb kommt man auch nicht "so" an das MAPIobject
http://msdn.microsoft.com/en-us/library ... 10%29.aspx
brandelh hat geschrieben:Hast du zufällig einen LINK der die Parameter (einfach) erklärt ?
hier von C. Beling
Code: Alles auswählen
////////////
//
// ApiSendMail_()
// GENERAL DOCUMENTATION
//
// iVars: CDO.ch
//
// CDO.Configuration
// CDO.Configuration http://msdn.microsoft.com/en-us/library/ms526318(v=exchg.10).aspx
// http://msdn.microsoft.com/en-us/library/ms526953(v=exchg.10).aspx
// Individual properties description: http://msdn.microsoft.com/en-us/library/ms526600(v=exchg.10).aspx
// CDO.Message http://msdn.microsoft.com/en-us/library/ms526453(v=exchg.10).aspx
// CDO error codes http://msdn.microsoft.com/en-us/library/ms526287(v=exchg.10).aspx
// http://www.cdolive.com/cdo11.htm with decimal values
// Examples http://www.paulsadowski.com/wsh/cdo.htm
//
// Xbase++ field initialization:
// The synthaxy to be used may be one or another:
// As write in MSN documentation:
// objMessage.Configuration.Fields.Item _("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.myserver.com"
// In Xbase++:
// 1) oFields:setProperty("Item", "http://schemas.microsoft.com/cdo/configuration/smtperver", "mail.server.com")
// 2) oFields:setProperty("Item", "cdosmtpserver", 'mail.example.com')
//
// FOR CONFIGURATINg NEWS GROUPS
// FieldName in :setProperty()
// "nntpauthenticate" - constante http://schemas.microsoft.com/cdo/configuration/nntpauthenticate
// See "smtpauthenticate"
// "postemailaddress" - constant http://schemas.microsoft.com/cdo/configuration/postemailaddress
// // The user's return email address for posted messages
// "postpassword" - constant http://schemas.microsoft.com/cdo/configuration/postpassword
// //The password used with postusername when authenticating
// // with an NNTP service if the "nntpauthenticate" field
// // is set to cdoBasic (1)
// "postusername" - constant http://schemas.microsoft.com/cdo/configuration/postusername
// //The username used with postpassword when authenticating to an NNTP
// // service if the nntpauthenticate field is set to cdoBasic (1).
// // The name must be the fully qualified domain account name, such
// // as (domain)\(username) when authenticating with a service participating
// // in an Windows NT domain system.
// "postuserreplyemailaddress" - constant http://schemas.microsoft.com/cdo/configuration/postuserreplyemailaddress
// // The reply email address. This value is used when
// // constructing the headers for posted messages
// "postusing" - constant http://schemas.microsoft.com/cdo/configuration/postusing
// // Specifies the method used when posting NNTP messages.
// // Values (defined in CDO.ch)
// // cdoPostUsingPickup := 1 -> Post the message using the local NNTP service pickup directory.
// // cdoPostUsingPort := 2 -> Post the message using NNTP over the network.
//
// FOR CONFIGURATION SMTP
// FieldName in :setProperty
// "cdosendemailaddress" - constant http://schemas.microsoft.com/cdo/configuration/sendemailaddress
// // The user's email address used when connecting to the SMTP service.
// "cdosendpassword" - constant http://schemas.microsoft.com/cdo/configuration/sendpassword
// // The password used to authenticate to an SMTP server using basic
// // Values (defined in CDO.ch)
// // cdoBasic := 1 Basic use clear-text authentication.
// // When using this option you must provide the user name and
// // password through the fields and sendusername sendpassword
// // dos campos sendusername e sendpassword
// // cdoAnonymous := 0 Not authenticate.
// // cdoNTLM := 2 The current process security context is used to authenticate
// // with the service.
// "cdosendusername" - constant http://schemas.microsoft.com/cdo/configuration/sendusername
// //The username for authenticating to an SMTP server using basic
// "cdosenduserreplyemailaddress" - constant http://schemas.microsoft.com/cdo/configuration/senduserreplyemailaddress
// // This value is normally set if the From address is not where email
// // replies should be sent.
// "cdosendusingmethod" - constante http://schemas.microsoft.com/cdo/configuration/sendusing
// // Specifies the method used to send messages.
// // If a local SMTP service is available, this field defaults to
// // Values (defined in CDO.ch)
// // cdoSendUsingPickup := 1 Send message using the local SMTP service pickup directory.
// // cdoSendUsingPort := 2 Send the message using the network (SMTP over the network).
// "cdosmtpauthenticate" - constante http://schemas.microsoft.com/cdo/configuration/smtpauthenticate
// // Specifies the authentication mechanism to use when authentication is required to send
// // messages to an SMTP service using a TCP/IP network socket.
// // If no value is set for this field, anonymous (no authentication) is assumed.
// // This field is used only if the field "cdoSendUsing"
// // is set to "cdoSendUsingPort".
// // These settings mean that messages are to be sent or posted over the network.
// // Values (defined in CDO.ch)
// // cdoBasic := 1 Basic use clear-text authentication.
// // When using this option you must provide the user name and
// // password through the fields and sendusername sendpassword
// // dos campos sendusername e sendpassword
// // cdoAnonymous := 0 Not authenticate.
// // cdoNTLM := 2 The current process security context is used to authenticate
// // with the service.
// "cdosmtpconnectiontimeout" - constante Long http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout
// // Indicates the number of seconds to wait for a valid socket to be established
// // with the SMTP service before timing out.
// // The default is 30 seconds.
// // This field is ignored unless the field CdoConfiguration.cdoSendUsingMethod
// // is set to cdoSendUsingPort (2).
// "cdosmtpserver" - constante http://schemas.microsoft.com/cdo/configuration/smtpserver
// // This field is used when the field "cdoSendUsing"
// // is set to cdoSendUsingPort.
// "cdosmtpserverport" - constante http://schemas.microsoft.com/cdo/configuration/smtpserverport
// // The port on which the SMTP service specified by the smtpserver field is
// // listening for connections.
// // The default and well-known port for an SMTP service is 25.
// "cdosmtpusessl" - constante http://schemas.microsoft.com/cdo/configuration/smtpusessl
// // Indicates that Secure Sockets Layer (SSL) should be used when sending messages
// // using the SMTP protocol over the network.
// // This field is only meaningful when the field CdoConfiguration.cdoSendUsingMethod
// // is set to CdoSendUsingPort. The default is False
//
//
// CDO.Message
// http://msdn.microsoft.com/en-us/library/ms526559(v=exchg.10).aspx
// :subject Objeto da mensagem
// :From (reserved in XBase++) The string in the From property represents the full messaging addresses of the
// message author or authors, as shown in the following example:
// "Jane Doe" <example@example.com>, <example@example.com>, example2@example.com
// Commas serve as address separators; however, commas are not parsed as separators when
// they appear in an address that is enclosed in double quotes, such as the following:
// "John Jones, Jr." <example@example.com>, "Jane Doe" <example@example.com>
// :To, :Cc, :Bcc Commas serve as address separators; however, commas are not parsed as separators when
// they appear in an address that is enclosed in double quotes, such as the following:
// 'example@example.com'
// ""John Jones, Jr." <example@example.com>"
// "example@example.com, "John Jones, Jr." <example@example.com>, "Jane Doe" <example@example.com>"
// :ReplyTo destinatário da resposta da mensagem.
// Assume: e-mail constante em :From
// :DSNOptions cdoDSNDefault 0 No delivery status notifications are issued.
// cdoDSNNever 1 No delivery status notifications are issued.
// cdoDSNFailure 2 Returns a delivery status notification if delivery fails.
// cdoDSNSuccess 4 Returns a delivery status notification if delivery succeeds.
// cdoDSNDelay 8 Returns a delivery status notification if delivery is delayed.
// cdoDSNSuccessFailOrDelay 14 Returns a delivery status notification if delivery succeeds,
// fails, or is delayed.
// See in CabDefs.ch cabMAIL_NOTIFY ...
// :KeyWords The keywords of a message can be useful for determining if the message is of
// interest to the reader, or for searching for relevant messages in a collection.
// The string in the Keywords property can represent a single keyword or multiple keywords.
// A keyword string can optionally contain spaces, such as the following:
// "1997 payroll"
// Multiple keywords in the list are separated by commas, as in the following example:
// "operating systems,Windows NT,functions"
//
// AddAttachment(<cFullPathName>) pode-se ter vários métodos
// Other many properties, also to send HTML, see the URL above
//
// 'The line below shows how to send using HTML included directly in your script
// objMessage.HTMLBody = "<h1>This is some sample message html.</h1>"
//
// 'The line below shows how to send a webpage from a remote site
// 'objMessage.CreateMHTMLBody "http://www.paulsadowski.com/wsh/"
//
// 'The line below shows how to send a webpage from a file on your machine
// 'objMessage.CreateMHTMLBody "file://c|/temp/test.htm"
//
// Author: Beling
// Date: 05.12.2012
// Revised:
//
/////
es gibt also noch jede Menge Parameter die noch nicht in diesem Thread berücksichtigt wurden.
ich würde ComLastMessage() in einem BEGIN SEQUENCE verwenden und das ganze, wie auch SOCmapi, im eigenen Thread laufen lassen.
übrigens : die CDO.CH erhält man mit
brandelh hat geschrieben:Ist für CDO Outlook erforderlich oder ist das direkt von Windows ?
CDO arbeitet über MAPI.
http://msdn.microsoft.com/en-us/library ... 10%29.aspx
es muss IMHO ein MAPI Client aktive sein wo sich CDO anmelden kann.
Anmerkung : normaler weise wird CDO mit Exchange Server und ASP verwendet.
http://msdn.microsoft.com/en-us/library ... 10%29.aspx
brandelh hat geschrieben:das führt aber zu der Fehlermeldung:
...
Hat das schon jemand gelöst ?
man sollte auch prüfen ob die Attachments wirkich raus gegangen sind ...
Code: Alles auswählen
FUNCTION SendAnonimousEMail_(cSmtpServer, nSendingMethod, nSmtpServerPort, lSmtpUseSsl,;
nAuthenticate, nConnectionTimeOut, cSenderName,;
cSenderPassword, cSenderEmail, cSenderReplyEmail,;
cSubject, cFrom, cTo,;
cCc, cBcc, cReplyTo,;
cHTMLBody, cTextBody, cKeyWords,;
aAttachment, nDSNOptions, cError)
LOCAL oThread, cId, lOk, nCount, nInd, nLen, hFree, cLocked
if !Empty(cTo)
cId := cTo
elseif !Empty(cCc)
cId := cCc
elseif !Empty(cBcc)
cId := cBcc
endif
if cId <> NIL
cId := ('E-mail to ' + cId)
endif
oThread := Thread():new(NIL, cId)
lOk := oThread:start({|| ApiSendMail_(cSmtpServer, nSendingMethod, nSmtpServerPort, lSmtpUseSsl,;
nAuthenticate, nConnectionTimeOut, cSenderName,;
cSenderPassword, cSenderEmail, cSenderReplyEmail,;
cSubject, cFrom, cTo,;
cCc, cBcc, cReplyTo,;
cHTMLBody, cTextBody, cKeyWords,;
aAttachment, nDSNOptions, @cError)})
if lOk
oThread:synchronize(0)
do While oThread:active
Sleep(10)
enddo
//
// Tendo em vista que CDO.Message pode reter os anexos como reservados até
// a finalização do processo que enviou a mensagem, forçaremos a
// execução do "Garbage Collector" do Xbase++ a fim de liberar todos os
// recursos usados por Thread(), encerrando-a imediatamente
oThread := NIL // Para forçar a liberação da Thread e recursos envolvidos
//
// Esperaremos até 15 segundos para ver se cada anexo já pode ser usado.
// Caso este tempo seja insuficiente, é acrescentada uma mensagem com o
// motivo no parâmetro <cError>.
nCount := 0
if !Empty(aAttachment)
nLen := Len(aAttachment)
for nInd := 1 to nLen
hFree := FOpen(aAttachment[nInd])
if hFree > 0
FClose(hFree)
nCount := 0
else
Sleep(50)
if ++nCount == 30
exit
endif
nInd -= 1
endif
next
endif
if nCount == 30
cLocked := ('Attachments: ' + aAttachment[nInd] + CR +;
'locked by System')
if Empty(cError)
cError := cLocked
else
cError += (cError + CR + cLocked)
endif
endif
lOk := !Empty(cError)
endif
RETURN lOk