Highlighted
Absent Member.
Absent Member.
981 views

[archive] COM Help

[Migrated content. Thread originally posted on 19 August 2008]

Hi,

Hopefully someone can help me here as I'm completely lost.

I usually have a crack at these now since Gisle's course, and usually can get somewhere.
But not in this case.
It seems that all I learned on the course has been thrown out the window?

OK, a colleague in work is using this to bypass the outlook security questions and found sample VB code which is working and attached.

I've attached the defination file I created yesterday.
Any pointers as to how I convert would be grately received.
i.e. when using outlook I do Create Application Of Outlook Handle In Outlook-Handle

But this thing is different?

Thanks,

Shaun



Public Function SendMessage() As Boolean
' The SendMessage() function reads user entered values and
' actually sends the message.

On Error Resume Next

Dim strRecip As String
Dim strRecipCC As String
Dim strSubject As String
Dim strMsg As String
Dim strAttachment As String

Dim objSafeMail, oItem

    strSubject = lclMailSubject
    strRecip = lclEmailAddress
    strMsg = " " + lclTemplateMsg
    strAttachment = lclDiskFileName
    If lclEmailAddressNo2 <> "" Then
        strRecipCC = lclEmailAddressNo2
    End If
    ' Any amount of validation could be done at this point, but
    ' at a minimum, you need to verify that the user supplied an
    ' Email address for a recipient.
    If Len(strRecip) = 0 Then
    strMsg = "You must designate a recipient."
    MsgBox strMsg, vbExclamation, "Error"
    Exit Function
    End If
   
    ' Assume success
    fSuccess = True

    ' Here's where the real Outlook Automation takes place
    If fSuccess = True Then
        'Set mItem = mOutlookApp.CreateItem(olMailItem)
       
        Set objSafeMail = CreateObject("Redemption.SafeMailItem")
        Set oItem = Application.CreateItem(0)
        objSafeMail.Item = oItem
       
        'mItem.Recipients.Add strRecip
        'mItem.SentOnBehalfOfName = "kpatterson@sysco-software.com"
        'mItem.ReplyRecipients.Add ("kpatterson@sysco-software.com")
       
        objSafeMail.Recipients.Add strRecip
        'objSafeMail.SentOnBehalfOfName = "kpatterson@sysco-software.com"
        'objSafeMail.ReplyRecipients.Add ("kpatterson@sysco-software.com")
       
        If strRecipCC <> "" Then
            'mItem.CC = strRecipCC
            objSafeMail.CC = strRecipCC
        End If
        'mItem.Subject = strSubject
        'mItem.Body = strMsg
       
        objSafeMail.Subject = strSubject
        objSafeMail.Body = strMsg
       
       
        ' This code allows for 1 attachment, but with slight
        ' modification, you could provide for multiple files.
        If Len(strAttachment) > 0 Then
            'mItem.Attachments.Add strAttachment
            objSafeMail.Attachments.Add strAttachment
        End If
        If lclEmailDirect = False Then
            'mItem.Save
            objSafeMail.Save
        Else
            'mItem.Send
            objSafeMail.Send
        End If
    End If
   
    If Err.Number > 0 Then fSuccess = False
    SendMessage = fSuccess
End Function
0 Likes
8 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] COM Help

Shaun,

Here's what I do for creating mail items:


    05 OUTLOOK-APP          HANDLE OF APPLICATION OF OUTLOOK.
    05 OUTLOOK-MAIL         HANDLE OF MAILITEM OF OUTLOOK.


...


CREATE @APPLICATION OF @OUTLOOK HANDLE IN OUTLOOK-APP.
MODIFY OUTLOOK-APP @CREATEITEM(0) GIVING OUTLOOK-MAIL.


...

Not sure if this will help or you are looking for something more specific.

Rob
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] COM Help

Thanks Rob,

That actually fixes something for me which appears to be new in V8.0 acubench.

But my problem which I now understand why is that redemption is not an application as such, maybe more so an extension to outlook?

So what I was looking for help on was the usage of the Redemption.dll

I just don't remember anything like this when I attended the advanced windows course?

Shaun
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] COM Help

I looks like the SafeMailItem is just the same as Outlook's MailItem.

So, perhaps you could just do this:


  05 REDEMPTION-MAIL-ITEM   HANDLE OF SAFEMAILITEM OF REDEMPTION.
  05 OUTLOOK-APP                 HANDLE OF APPLICATION OF OUTLOOK.
  05 OUTLOOK-MAIL                HANDLE OF MAILITEM OF OUTLOOK.

...

CREATE SAFEMAILITEM OF REDEMPTION HANDLE IN REDEMPTION-MAIL-ITEM.
CREATE @APPLICATION OF @OUTLOOK HANDLE IN OUTLOOK-APP.
MODIFY OUTLOOK-APP @CREATEITEM(0) GIVING OUTLOOK-MAIL.
MODIFY REDEMPTION-MAIL-ITEM @ITEM = OUTLOOK-MAIL AS VT-DISPATCH

...

At least I think this will get you closer anyways...
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] COM Help

Good man Rob.

Thanks very much for that, I think I'm ok with the rest of it.
I did use the axdeftool to look at the defination generated, but that just confused me more.

Much Appreciated.

Shaun
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] COM Help

Good Luck, Shaun. Glad I could help.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] COM Help

Shaun, Rob

Could one of you help me. I get stil de warning in Outlook with sourcelines I found in this post.

Thanks already
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] COM Help

Sure, I can try.

Whats happening then?
Are you getting security warnings from Outlook?
You cannot bypass these unless you use that redemption dll

And alternative approach which I took instead was to use MS Exchange directly.
I found that communication directly with outlook was talking far too long.
For example - one particular user would run invoice prints which would have in the region of 250 - 300 invoices to email per batch.

What I did was adopt an autoemailer type program which simply runs as a scheduled task/cron every X minutes and send out whatever emails have been issued in various parts of our software.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] COM Help

Shaun, yes I get the securty warning and I installed redemption.

This is the start:

CREATE APPLICATION OF OUTLOOK
HANDLE IN OUTLOOK-APP.
IF OUTLOOK-APP = ZERO
* (FOUT BIJ OPENEN OUTLOOK)
MOVE "01" TO NUMMER-BDSP
MOVE "99" TO STATUS-OUTL
PERFORM R95
END-IF.
CREATE SAFEMAILITEM OF REDEMPTION
HANDLE IN REDEMPTION-MAIL-ITEM.
MODIFY OUTLOOK-APP GETNAMESPACE("MAPI")
GIVING NAMESPACE-HANDLE.

And here is de sending part:

F13 SECTION.
******************************************************
* VERZENDEN MAIL-BERICHT *
******************************************************
F1301.
MODIFY OUTLOOK-APP, CREATEITEM (OLMAILITEM)
GIVING OUTLOOK-MAIL
MODIFY REDEMPTION-MAIL-ITEM @ITEM =
OUTLOOK-MAIL AS VT-DISPATCH
MODIFY OUTLOOK-MAIL @SUBJECT H11-ONDERWERP
IF HTML-OUTL
MODIFY OUTLOOK-MAIL @HTMLBODY H11-BERICHT
END-IF.
IF TEKST-OUTL
MODIFY OUTLOOK-MAIL @BODY H11-BERICHT
END-IF.
MODIFY OUTLOOK-MAIL @TO H11-MAILNAAR
IF H11-BIJLAGE NOT = SPACES
INQUIRE OUTLOOK-MAIL ATTACHMENTS IN ATTACH-HANDLE
MODIFY ATTACH-HANDLE @ADD
(H11-BIJLAGE, OLBYVALUE, 1, "Zie bijlage")
END-IF
MODIFY OUTLOOK-MAIL @SEND ()
DESTROY OUTLOOK-MAIL
MOVE 1 TO I01
.
F1399.
EXIT.

Where do I something wrong. This my first project and I know almost nothing about other lanquages.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.