Subject: | Re: Upgrading to Win 10 and P11
| Date: | Thu, 17 Sep 2020 08:43:44 +0200
| From: | "Ian Espie" <ianespie@mweb.co.za>
| Newsgroups: | pnews.paradox-programming
|
Wow Thies - thank you very much it is very useful - I will give it a try.
Ian.
"Thies Grimm" wrote in message news:5f61d740$1@pnews.thedbcommunity.com...
weil ihr es seid, Leslie und Günther:
**************************************************
{ <Doku> **** **** **** **** **** **** **** **** **** **** ///
@function cmOLSendMail
@category
@Keywords
@abstract liest die Mailvariable aus und erzeugt per
OLE eine entsprechende Outlook-Mail
@Remarks
@Parameter
@Return
@Examples
@todo
@Uses Outlook
@Client
@Status
@ChangeLog
; // **** **** **** **** **** **** **** **** **** **** </Doku>}
; //
method cmOLSendMail(
var msg Mail
) Logical
var
dyn dynArray[] String
stSubject String
stMsgText String
dynAddress dynArray[] Smallint
dynAttachment dynArray[] String
stAddress String
siAddrtype Smallint
stFilename String
stMoniker String
liPos LongInt
sApp String
oOutlook, oItem,
oRec, oAtt, oTmp,
oInspector OLEAuto
sSig String
ar Array[] String
si Smallint
li Longint
element String
endVar
; // **** **** **** **** **** **** **** **** **** **** ///
; // Outlook gestartet?
; // **** **** **** **** **** **** **** **** **** **** ///
enumWindowHandles(dyn, "mspim_wnd32")
if dyn.size() = 0 then
msgstop("Achtung",
"Starten Sie bitte erst Outlook und " +
"versuchen es dann noch einmal!")
return False
endIf
; // **** **** **** **** **** **** **** **** **** **** ///
; // Mail Variable auslesen
; // Adressen, Betreff, Nachricht, Anhänge
; // **** **** **** **** **** **** **** **** **** **** ///
for li from 1 to msg.getAddressCount()
msg.getAddress( li, stAddress, siAddrtype )
dynAddress[stAddress] = siAddrtype
endFor
stSubject = msg.getSubject()
stMsgText = msg.getMessage()
for li from 1 to msg.getAttachmentCount()
msg.getAttachment(li, stFilename, stMoniker, liPos)
dynAttachment[li]=stFilename
endfor
; // **** **** **** **** **** **** **** **** **** **** ///
; // Outlook
; // **** **** **** **** **** **** **** **** **** **** ///
sApp = "Outlook.Application"
; // oOutlook = Outlook.Application
if NOT oOutlook.open(sApp) then
msgStop("Achtung",
"Fehler beim Öffnen des OLE-Objektes " +
sApp + ".")
return False
endIf
; // oItem = new Microsoft Outlook item
try
oItem = oOutlook.createItem(0)
onFail
errorLog(UserError,
"Trouble in Outlook. (oOutlook.createItem)")
errorshow()
return False
endTry
; // cmOLEAutoShowInfos(oItem,2)
; // Empfänger, Recipients
try
oRec = oItem.Recipients
onFail
errorLog(UserError,
"Trouble in Outlook. (oItem.Attachments)")
errorshow()
return False
endTry
forEach element in dynaddress
switch
case dynaddress[element] = 1: oRec^add(element)
case dynaddress[element] = 2: oItem.CC = element
case dynaddress[element] = 3: oItem.BCC = element
endSwitch
endForEach
oRec.close()
; // Betreff, subject
oItem.subject = stSubject
; // Message
; // Signatur erst auslesen, um sie am Ende vom Body
; // wieder einzufügen. Signatur geht sonst verloren.
oItem.display()
sSig = oItem.Body
; // Message und Signatur wieder hinzufügen
oItem.Body = stMsgText + "\n" + sSig
; // Anhang, Attachments
if dynAttachment.size() > 0 then
try
oAtt = oItem.Attachments
onFail
errorLog(UserError,
"Trouble in Outlook. (oItem.Attachments)")
errorshow()
return False
endTry
forEach element in dynAttachment
oTmp = oAtt^add(dynAttachment[element])
otmp.close()
endForEach
oAtt.close()
endIf
; // Outlook nach vorne holen
try
;oItem.Display()
; Display-Methode wird laut MSDN nur noch aus
; Kompatibilitätsgründen unterstützt, besser ist die
; Activate-Methode des Inspector-Objects zu nutzen
oInspector = oItem.getInspector()
oInspector.activate()
onFail
errorShow()
endTry
; // OLE-Objekte wieder schließen
oInspector.close()
oItem.close()
oOutlook.close()
errorClear()
return True
endMethod
**************************************************
=?UTF-8?Q?G=c3=bcnter?= <info@NoSpam-mk-news.com> wrote:
>Leslie,
>
>please give a little HowTo for the Code with COM/automation, because we
>tell our users to install Outlook 32 Bit for the function of mailto.
>
>Günter, Paradox 9
>
>Am 15.09.2020 um 05:35 schrieb Leslie:
>>>
>>
>> We no longer use MAPI for Outlook given that on Windows 64 with Outlook
>> 64, MAPI causes a bunch of issues called from a 32 Bit application -
>> even as trivial as the background stationery not happening correctly.
>>
>> So instead we now use COM/automation (Ole in old speak) to send emails
>> when Outlook is the default mail application and it just works.
>>
>>
>>
>>
|