Solved

Object doesn't support this property or method

Posted on 2014-02-04
6
1,759 Views
Last Modified: 2014-02-19
Hello~
Trying to recode from Groupwise to Outlook and running into an error. Right now getting Object Doesn't support this property or method on line 53. I got this code off MSDN so I am not sure why it is not happy? I have Outlook references set up as well.  Outlook is open at this point. I'm not even getting to the next section to see if I need to re-write that. I also tried adding this line: Set olApp = CreateObject("Outlook.Application") before line 53 and that did nothing either. Help?
Public Function SendEmail(AddressTo As Variant, Header As String, Message As String, PriorityHigh As Boolean, _
                            Optional AddressCC As Variant, Optional AddressBCC As Variant, _
                            Optional FileAttach As Variant, Optional MessageFromText As Variant)
    '  Function is used to send e-mails through the Groupwise Client
    '  Groupwise must be installed for the function to work
    '  variables
    '  FileAttach tilda delimited string of file names - maximum attachments handled by code is six
    'On Error GoTo Err_Handler
    ' Address Array
    '    Address:  (0, i)=address; mastrRecTo(1, i)=display name
    Dim strTemp As String
    Dim bAttachment As Boolean
    Dim varAttach(5) As Variant
    Dim ccAddress(50, 0) As Variant
    Dim lngCount As Long
    Dim varProxies As Variant
    Dim olApp As New Outlook.Application
    Dim olMailItem As Outlook.MailItem  ' An Outlook Mail item
    Dim i As Integer
    Dim k As Integer
    
    '  If not attachments send through centralized processing
    If IsMissing(FileAttach) = True Then
        Call SendSQLEmail(AddressTo, Header, Message, AddressCC, AddressBCC, FileAttach, MessageFromText)
        
        Exit Function
    End If
    
    
    
    
    If DatabaseAtHome = False Then
        If IsMissing(FileAttach) = True Then
            bAttachment = False
        Else
            bAttachment = True
            '  parse out the names
            k = 0
            Do
                i = InStr(FileAttach, "~")
                If i = 0 Then
                    varAttach(k) = FileAttach
                Else
                    varAttach(k) = Left(FileAttach, i - 1)
                    FileAttach = Mid(FileAttach, i + 1)
                End If
                k = k + 1
                If k > 5 Then Exit Do
            Loop Until i = 0
        End If
    
        ''''Set olApp = New Outlook.Application
        Set olMailItem = olApp.CreateItem(olMailItem)

        With olMailItem
        ''''With oApp
            ''''.Login
            ''''.BodyText = Message
            ''''.Subject = Header
            ''''.RecTo = AddressTo                                  '  Primary Recipient
            .TO = AddressTo
            .Subject = Header
            .Body = Message

            
            If IsMissing(AddressCC) = False Then                '  carbon copy if present
                .RecCc = AddressCC
            End If
            
            If IsMissing(AddressBCC) = False Then               '  blind cardon copy if present
                .RecBc = AddressBCC
            End If
            If IsMissing(varAttach) = False Then                ' Attachments if present
                .FileAttachments = varAttach
            End If
            If IsMissing(MessageFromText) = False Then          '  From Text if Present - user name to appended
                .FromText = MessageFromText                     '  PeopleCenter (User Name)
            End If
            If PriorityHigh = True Then                         '  Message priority id either high or standard
                .Priority = "High"
            Else
                .Priority = "Standard"
            End If
            strTemp = .CreateMessage
            .ResolveRecipients strTemp
            If IsArray(.NonResolved) Then MsgBox "Some unresolved recipients."
            .SendMessage strTemp
            .DeleteMessage strTemp, True
        End With
    
Exit_Here:
        Set olApp = Nothing
        Set olMailItem = Nothing
        
    Else
        MsgBox "Header: " + Header + vbCrLf + "Message: " + Message, vbInformation, "E-Mail Message"
    End If
    
    Exit Function
Err_handler:
    MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical
    Resume Exit_Here

End Function

Open in new window

0
Comment
Question by:dminx13
6 Comments
 

Author Comment

by:dminx13
ID: 39834098
The end result is creating a new mail message with attachments and sending it to a list of people.
0
 
LVL 38

Accepted Solution

by:
Jim P. earned 250 total points
ID: 39834179
I used to have to work with Groupwise at my last company. I found that trying to use an Outlook Application to send e-mails from VB was always a problem.

So I developed a  routine that works off the vbSendMail.dll. I had a routine in Access that would copy the dll to the local machine from a network location.

Then the function in this question is what I would use to send the file.

That way I didn't have to worry if Outlook or Outlook Express was loaded on the PC.
0
 
LVL 8

Expert Comment

by:TheNautican
ID: 39834189
Try to uncomment out line 52
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:dminx13
ID: 39834552
Jim P - We run Outlook off of a packaged environment. It isn't installed locally. It will always be Outlook not express.

We are moving to Windows 7 and from what I have heard I will have very little access to anything locally so would this work in a locked down environment?

TheNautican. I have. Same error :-(
0
 
LVL 38

Expert Comment

by:Jim P.
ID: 39834585
Jim P - We run Outlook off of a packaged environment. It isn't installed locally. It will always be Outlook not express.

I actually haven't had to try it in a locked down environment, so I'm not able to answer that directly.

The way I always did it was to set a reference (VBA window (<Alt>+<F11> --> Tools --> References) in the the DB and then selected the Send Mail object from the list. The file was copied to the C:\Windows\System32 folder already. But in a more restrictive environment  you can copy the vbSendMail.dll to any "universal" location and then go into the references and add it from that location. It will work the same way as long as the location is the same as it is in the references.

It is not pretty but it works.
0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 39835331
You can also place it in the same directory as your database. Access should try to resolve the reference there fairly high up in the pecking order.

FWIW, I use vbMAPI (www.everythingaccess.com) anytime I need to work with Outlook. It's easy to deploy (you do nothing - everything travels with the database), and it's simple to use. Sort of like Redemption, but better (IMO).
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Ms Access VBA Variables 6 26
Access Update Query 1 20
Need help constructing a conditional update query 16 43
MS Access Delete All Excel sheets 1 8
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question