Skip to main content

[archive] Email with Outlook Com Object

  • April 10, 2007
  • 4 replies
  • 1 view

[Migrated content. Thread originally posted on 10 April 2007]

Hello Everyone,
has someone a code example on how to invoke Outlook COM object form AcucobolGT to send e-mail with attachment?
TIA Giovanni.

4 replies

[Migrated content. Thread originally posted on 10 April 2007]

Hello Everyone,
has someone a code example on how to invoke Outlook COM object form AcucobolGT to send e-mail with attachment?
TIA Giovanni.
Hi Giovanni,

We're doing it, in various parts of our application.
This code comes from our purchase ordering system, user places PO and the system then emails to supplier with an attachment.

I've just put in bits of the code.
Here's the handles
77 outlook-handle handle of application.
77 mail-handle handle of mailitem.
77 attach-handle handle of attachments.

Here's the code which builds and sends the email
CREATE APPLICATION OF OUTLOOK HANDLE IN OUTLOOK-HANDLE
MODIFY OUTLOOK-HANDLE, CREATEITEM (OLMAILITEM) GIVING
MAIL-HANDLE
MODIFY MAIL-HANDLE @SUBJECT "Purchase Order"
MODIFY MAIL-HANDLE @TO WS-EMAIL-ADDRESS
INQUIRE MAIL-HANDLE ATTACHMENTS IN ATTACH-HANDLE
MODIFY ATTACH-HANDLE @ADD(WS-EMAIL-ATTACHMENT,
OLBYVALUE, 1, "SEE ATTACHMENT")
MODIFY MAIL-HANDLE @SEND()
DESTROY MAIL-HANDLE
DELETE FILE EMAIL-FILE

WS-EMAIL-ADDRESS, WS-EMAIL-ATTACHMENT and EMAIL-FILE are just a PIC X(whateversize)

You'll need to create a .def file for outlook and put the copy in SPECIAL-NAMES.

You'll also encounter security issues with outlook, these can be bypassed with a seperate dll which I think is called safemail.

I can get the proper name of the seperate dll if you wish, but we just let our users live with outlook asking for permission.
We also have a declaratives section just incase the user decides to prevent the email getting sent if that makes sense.
DECLARATIVES.
OBJECT-EXCEPTION-HANDLING SECTION.
USE AFTER EXCEPTION ON OBJECT.
OBJECT-EXCEPTION-HANDLER.
CALL "C$EXCEPINFO" USING ERROR-INFO, WS-ERR-SOURCE
WS-ERR-DESC
END DECLARATIVES.

Shaun

[Migrated content. Thread originally posted on 10 April 2007]

Hello Everyone,
has someone a code example on how to invoke Outlook COM object form AcucobolGT to send e-mail with attachment?
TIA Giovanni.
ThankU very very much, it's what I was lookin' for: it works fine!
Bye Giovanni.

[Migrated content. Thread originally posted on 10 April 2007]

Hello Everyone,
has someone a code example on how to invoke Outlook COM object form AcucobolGT to send e-mail with attachment?
TIA Giovanni.
Talked to another VB developer in the office.
The other dll to bypass the security issues is not safemail.
Its outlook redemption.
See here
http://www.dimastr.com/redemption/

Shaun

[Migrated content. Thread originally posted on 10 April 2007]

Hello Everyone,
has someone a code example on how to invoke Outlook COM object form AcucobolGT to send e-mail with attachment?
TIA Giovanni.
Hi Shaun,
I know Redemption, it's useful expecially for developing ComAdd-in dll's in VB (I'm a VB prog too), but it has the cons of being not really free for commercial use and to be deployed ina package if you use it: I'd prefer to use what the client can offers by itself, if I can. Safety issues however are not so strict in MsOlk2000 and MsOlk2003, only in MsOlkXp are really boring, in fact we don't support that version due to those problems.
Again thanks for help! bye Giovanni.