Solved

Object doesn't support this property or method

Posted on 2014-02-04
6
1,748 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now