Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Object doesn't support this property or method

Posted on 2014-02-04
6
Medium Priority
?
1,811 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 1000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1000 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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
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…
Suggested Courses

885 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