Solved

Object doesn't support this property or method

Posted on 2014-02-04
6
1,755 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
View vs Edit mode enhancements 12 40
Syntax Error in Query 7 31
data analyst 3 50
Open CSV, modify and save as xls from Access 12 19
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

895 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

13 Experts available now in Live!

Get 1:1 Help Now