Subject: | Re: Upgrading to Win 10 and P11
| Date: | 17 Sep 2020 08:39:38 -0400
| From: | "Thies Grimm" <thies.grimm@t-online.de>
| Newsgroups: | pnews.paradox-programming
|
create a from with a button:
method pushButton(var eventInfo Event)
var
m Mail
endVar
m.addAddress("JDOE")
m.addAddress("SSMITH", MailAddrCC)
m.setSubject("Final sales numbers")
m.setMessage("The final sales numbers are attached")
; m.addAttachment("SALES.TXT")
if not cmOLSendMail(m) then
errorshow()
endIf
endMethod
"Ian Espie" <ianespie@mweb.co.za> wrote:
>How do you invoke this code from a button - I am battling - maybe I am
>missing something? Appreciate the help. 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.
>>>
>>>
>>>
>>>
|