Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Redemption

Status
Not open for further replies.

carlp69

IS-IT--Management
Sep 23, 2003
157
GB
I am trying to test outlook redemption but with no look.

I have install the reference and tried to execute the following code but keep getting the error - "Compile Error method or data member not found".

Am i missing something?

Carlp
 
carlp, yes you are missing something, your code sample. :) If you post it I will try to give you some help. It sounds like you have a variable declaration as an object that does not exist or a variable not declared as the correct or any object. This can sometimes be a spelling error. any way will look at your code once it is up.

Redapples

Want the best answers? See FAQ181-2886

 
DOH !!

Dim SafeItem, oItem
Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of Redemption.SafeMailItem
Set oItem = Application.CreateItem(0) 'Create a new message
SafeItem.Item = oItem 'set Item property
SafeItem.Recipients.Add "somebody@somewhere.com"
SafeItem.Recipients.ResolveAll
SafeItem.Subject = "Testing Redemption"
SafeItem.Send
 
Righto, I had not used redemption before however having looked at it today I managed to get this example to work.
I notice this is the example given on the website for redemption and (if I'm honest) its a bit sloppy to not give the correct syntax to get this to work nor to mention that it works in conjunction with Outlooks library.

Be sure first of all to include your outlook reference, mine was 9, then in the line
Code:
Set oItem = Application.CreateItem(0) 'Create a new message
include the word Outlook before application. It should read
Code:
Set oItem = Outlook.Application.CreateItem(0) 'Create a new message

This should work for you now. 1 question why are you using redemption? I am not experiencing any problems with just the outlook lib.


Want the best answers? See FAQ181-2886

 
I am trying redemption to try and get around the security in Outlook XP.

The one asking for confirmation everytime I try and mail via Access.

Any other ideas ?

Cheers

Carl
 
This security is built in to Outlook 2000 after sp2 (i have sp3) but dont get the kind of behaviour discussed on the redemption website. I even hit the MAPI in Access to store information in Public folders of an Exchange server without the behaviour reported. dont know that I'm doing anything special. What are you trting to do specifically just send email?

Code:
Function addmailaddy(strFirstName, strSecondName, strEmailAddy)
    Dim ol As Outlook.Application
    Dim olns As Outlook.NameSpace
    Dim objAllFolders As MAPIFolder
    Dim objPublicFolders As MAPIFolder
    Dim objFolder As MAPIFolder
    Dim objAllContacts As Outlook.Items
    Dim Contact As Outlook.ContactItem
    Dim check As Boolean
    Dim lngindex As Long
    Dim strEmail As String
    Dim i As Integer

    Set ol = Outlook.Application
    Set olns = ol.GetNamespace("MAPI")
    Set objAllFolders = olns.Folders("Public Folders")
    Set objPublicFolders = objAllFolders.Folders("All Public Folders")
    Set objFolder = objPublicFolders.Folders("GHN Contacts")
    Set objAllContacts = objFolder.Items
    On Error GoTo ErrHandler
    
    strEmail = strEmailAddy
    
    
    If Not IsNull(strEmailAddy) Then '1
        Call checkalreadythere(check, lngindex, strEmailAddy, strFirstName, strSecondName)
        If check Then '2
            Exit Function
        Else '2
            If lngindex = 1 Then '3
                lngindex = MsgBox("An entry exists for this person with the E-mail:" _
                        & Chr(13) & strEmailAddy & Chr(13) & "Change the address in the Address book?", vbYesNo)
                If lngindex = 6 Then '4
                    i = 1
                    Do While lngindex = 6
                    Set Contact = objAllContacts.Item(i)
                        If Contact.FIRSTNAME = strFirstName And Contact.LastName = strSecondName Then
                            '5
                            lngindex = 0
                            Contact.Email1Address = strEmail
                            Contact.Save
                        End If '5
                    i = i + 1
                    Loop
                Else '4
                    Exit Function
                End If '4
            Else '3
                Set Contact = objAllContacts.Add(olContactItem)
                Contact.FIRSTNAME = strFirstName
                Contact.LastName = strSecondName
                Contact.Email1Address = strEmailAddy
                'Contact.Display (True)
                Contact.Save
            End If '3
        End If '2
    Else
        Exit Function
    End If '1
   
    Set ol = Nothing
    Set olns = Nothing
    Set objAllFolders = Nothing
    Set objPublicFolders = Nothing
    Set objFolder = Nothing
    Set objAllContacts = Nothing
    Set Contact = Nothing
ExitHere:
Exit Function
ErrHandler:
    Select Case Err.Description
    Case "Array index out of bounds."
     'should not be able to get here but just in case
        Exit Function
    End Select
    
    Select Case Err.Number
    Case 13
    i = i + 1
    Resume
    Case Else
        MsgBox "Err: " & Err.Number & Err.Description & Err.HelpFile, vbCritical
    End Select
End Function


Function checkalreadythere(ByRef isthere, ByRef lngfound, ByRef strEmail, ByRef strFirstName, ByRef strSecondName)
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim fld As DAO.Field
    Dim i
    Dim strConnect As String

    strConnect = "Exchange 4.0;MAPILEVEL=\Outlook Address Book\;TABLETYPE=1;user = sconnell"
   
    Set db = OpenDatabase("c:\temp\", False, False, strConnect)
    Set rs = db.OpenRecordset("GHN Contacts")
    rs.MoveFirst
    i = 1
    
    'rs.FindFirst ("First = " & txtfirstname)
    Do Until i = -1 Or i = rs.RecordCount
    If rs!First = strFirstName Then '3
        If rs!Last = strSecondName Then '2
            If rs![E-mail address] = strEmail Then '1
                isthere = True
                i = -2 'next loop will be -1 thus ending loop
            Else
                strEmail = rs![E-mail address]
                lngfound = 1
                isthere = False
                i = -2 'next loop will be -1 thus ending loop
            End If '1
         End If '2
    End If '3
    i = i + 1
    rs.MoveNext
    Loop
    Set db = Nothing
    Set rs = Nothing
End Function
These functions add an email to a public folder in exchange after checking whether it is there or not. If I run it in break mode I sometimes get a security warning from Outlook but in run mode it works fine.

Code:
Private Sub DIRECTEMAIL_DblClick(Cancel As Integer)
    Dim objOutlook As Object
    Dim objItem As Object
    Dim strMailTo  As String
    Dim strName
    Dim strtype
    Dim iIndid
    
    On Error GoTo starterror
    

    'Create a Microsoft Outlook object.
    Set objOutlook = CreateObject("Outlook.Application")

    'Create and open a new contact form for input.
    Set objItem = objOutlook.CreateItem(olMailItem)
    DIRECTEMAIL.SetFocus
    strMailTo = DIRECTEMAIL.Text
    If strMailTo <> &quot;&quot; Then 'Not IsNull(strMailTo) Or
    
    objItem.To = strMailTo
    objItem.Display
    End If

    'Quit Microsoft Outlook.
    Set objOutlook = Nothing
   
ExitHere:
    Exit Sub

starterror:
    Select Case Err.Number
        Case Else
            MsgBox &quot;An error occured: &quot; & Err.Number _
            & &quot; &quot; & Err.Description
    End Select
    
End Sub

this sends an email no warnings here. what happens if you run this? Have got Office XP here but we( me and another developer) decided only to have one of us using it to test back compatability. maybe I should try running it on his machine.



Want the best answers? See FAQ181-2886

 
Works fine, but I don't want any user intervention.

It needs to be an automated email sent from the form after a record is created.

If I change the 'objItem.display' to 'objItem.Send' the security pops back up.

Any more ideas?

Thanks

Carl
 
will have to do some testing in XP have you tried sendobject?

If all else fails what happens with the modification to the redemption example?

As I say it worked for me but then I have not tried it with XP.

Want the best answers? See FAQ181-2886

 
I have done a lot of research into this and got no where fast.



Questions regarding the Outlook Security prompt are asked very frequently.
The most complete answer has been provided by Outlook MVP Sue Mosher and is
as follows:

BEGIN QUOTED MATERIAL:

&quot;The security dialogs that pop up when an application tries to access
certain Outlook properties and methods are designed to inhibit the spread of
viruses via Outlook; see
If you are a standalone
user, Outlook provides no way to suppress this behavior. However, you can
use a free tool called Express ClickYes
( to click the security
dialog buttons automatically. Beware that this means if a virus tries to
send mail using Outlook or gain access to your address book, it will
succeed.

&quot;If you're the administrator in an Exchange Server environment, you can
reduce the impact of the security prompts with administrative tools. See

&quot;If it's an application you wrote yourself, you can use one of these
approaches to redo the program:

-- Use Extended MAPI (see and C++
or Delphi; this is the most secure method and the only one that Microsoft
recommendeds.

-- Use Redemption ( a third-party
COM library that wraps around Extended MAPI but parallels the Outlook Object
Model

-- Use SendKeys to &quot;click&quot; the buttons on the security dialogs that your
application may trigger. See
for a link to sample
code.

-- Program the free Express ClickYes
( tool to start suspended
and turn it on only when your program needs to have the buttons clicked
automatically.&quot;

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers

END OF QUOTED MATERIAL




--
Cheryl Fischer


seems about the most comprehensive.

so this brings us back round to the redemption model. I have seen a different example of how to use redemption that creates an outlook mail item then assigns the mailitem into a Safemail.item object like the line way back at the top of this thread.

so something like this (a composite of both)
Code:
   Dim objOutlook As Object
    Dim objItem As Object
    Dim strMailTo  As String
    Dim strName
    
    On Error GoTo starterror

    'Create a Microsoft Outlook object.
    Set objOutlook = CreateObject(&quot;Outlook.Application&quot;)

    'Create and open a new contact form for input.
    Set objItem = objOutlook.CreateItem(olMailItem)
    DIRECTEMAIL.SetFocus
    strMailTo = DIRECTEMAIL.Text
    If strMailTo <> &quot;&quot; Then 
    
    objItem.To = strMailTo
    Dim SafeItem, oItem
    Set SafeItem = CreateObject &quot;Redemption.SafeMailItem&quot;)
   'Create an instance of Redemption.SafeMailItem
   SafeItem.Item = objItem 'set Item property
   SafeItem.Subject = &quot;Testing Redemption&quot;
   SafeItem.Send

so in effect what you are doing is creating an outlook object then wrapping this object up into a safemail object which is then sent.

Or at least that seems to be the case.

How have you got on with this.

BTW I have seen a number of post suggesting using CDO but this is a red herring, a M$ article on CDO expressly states that the security in Outlook is extended to CDO.

Redapples.

Want the best answers? See FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top