Solved

Microsoft's clsSendObject.SendObject doesn't work for me

Posted on 2006-07-20
12
414 Views
Last Modified: 2008-01-09
I'm having a problem with Docmd.SendObject so I followed Microsoft's code solution (using clsSendObject) but the code doesn't work.  I get "type mismatch" error on the call:
      clsSendObject.SendObject acFormatHTML, strName, , , strSubject, strMessage, False    

So then I tried the following call and got "Object Variable or with block variable not set" error on the call:
      clsSendObject.SendObject acSendNoObject, , accOutputTXT, "schmir1", , , "xxx"

Microsoft's code is listed at:
http://support.microsoft.com/?kbid=260819



0
Comment
Question by:schmir1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
12 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 17150068
so whats clsSendObject, its a variable of type accSendObject right?

Did u instanstiate it? I mean did u type in

dim clsSendObject = new accSendObject

0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 17150572
what's the problem you're having with the Docmd.SendObject command in the first place?
0
 

Author Comment

by:schmir1
ID: 17157533
Here is some more details:

I'm getting a type mismatch on intFormType in call below:

clsSendObject.SendObject intFormType, strForm, acFormatHTML, strName, , , strSubject, strMessage, False   'HTML=easier to read

I declare my mail functions as:
Sub Send_EMail(strName As String, strSubject As String, strMessage As String, strForm As String, _
               Optional intFormType As Access.AcSendObjectType = acSendNoObject, Optional Do_not_ask As Boolean)

Microsoft declares there clsSendObject.SendObject as follows:
Public Sub SendObject(Optional ObjectType As Access.AcSendObjectType = acSendNoObject, _
                      Optional ObjectName, _
                      Optional OutputFormat As accSendObjectOutputFormat, _
                      Optional EmailAddress, _
                      Optional CC, _
                      Optional BCC, _
                      Optional Subject, _
                      Optional MessageText, _
                      Optional EditMessage)

0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 65

Expert Comment

by:rockiroads
ID: 17157678
How did u define and set clsSendObject
0
 

Author Comment

by:schmir1
ID: 17157695
As follows:
  Dim clsSendObject As accSendObject
 
  Set clsSendObject = New accSendObject
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17157717
and what is

intFormType

defined as

an integer?
0
 

Author Comment

by:schmir1
ID: 17157722
Sub Send_EMail(strName As String, strSubject As String, strMessage As String, strForm As String, _
               Optional intFormType As Access.AcSendObjectType = acSendNoObject, Optional Do_not_ask As Boolean)
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17157747
I will look at this later, Ive got to go
will post comments
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17257918
Hi schmir1
Sorry about not responding earlier, I lost this bookmark and have been looking for it. Well I finally found it!


Anyways, I copied the code from MS and pasted it as a CLASS (not module) and saved it as accSendObject

I then took this line

clsSendObject.SendObject acSendNoObject, , accOutputTXT, "schmir1", , , "xxx"

And tried to work that, this is what I did

    Dim clsSendObject As accSendObject
   
   
    Set clsSendObject = New accSendObject
    clsSendObject.SendObject acSendNoObject, , accOutputTXT, "some@email.com", , , "xxx"
    Set clsSendObject = Nothing


And I had no problems whatsoever



With your other line

 clsSendObject.SendObject acFormatHTML, strName, , , strSubject, strMessage, False

You have got this wrong

the first parameter is send type i.e. acSendNoObject, acSendReport etc, not acFormatHTML
the second parameter is name of object (or nothing if no object)
the third parameter is the output type

now only 4 types are supported

accOutputRTF
accOutputSNP
accOutputTXT
accOutputXLS

there is no html output type (see my post after this on using html types)

The final line that worked for me was this

clsSendObject.SendObject acSendNoObject, , accOutputHTML, "some@mail.com", , , strSubject, strMessage, True


0
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 17257919
MODIFYING CODE TO HANDLE HTML

I think the reason why its not supported is perhaps it can't be done properly? I dont know. Have a look at this

If u want to cater for html format, u have to modify the class accSendObject

this is what u can try

Look for the enum accSendObjectOutputFormat and modify
e.g.
Public Enum accSendObjectOutputFormat
    accOutputRTF = 1
    accOutputTXT = 2
    accOutputSNP = 3
    accOutputXLS = 4
    accOutputHTML = 5
End Enum

Next, look for the function called GetExtension and modify
e.g.

Private Function GetExtension(ObjectType As Long) As String
    Select Case ObjectType
        Case 1 'RTF
            GetExtension = ".RTF"
        Case 2 'TXT
            GetExtension = ".TXT"
        Case 3 'SNP
            GetExtension = ".SNP"
        Case 4 'XLS
            GetExtension = ".XLS"
        Case 5 'HTM
            GetExtension = ".HTML"
    End Select
End Function

And now modify the function below that, GetOutputFormat
e.g.
Private Function GetOutputFormat(ObjectType As Long)
    Select Case ObjectType
        Case 1 'RTF
            GetOutputFormat = Access.acFormatRTF
        Case 2 'TXT
            GetOutputFormat = Access.acFormatTXT
        Case 3 'SNP
            GetOutputFormat = Access.acFormatSNP
        Case 4 'XLS
            GetOutputFormat = Access.acFormatXLS
        Case 5 'HTM
            GetOutputFormat = Access.acFormatHTML
    End Select
End Function


0
 

Author Comment

by:schmir1
ID: 17272872
Thanks.  It works great.
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17273202
I would of done it sooner had I not lost the bookmark!
There are 2 other questions I need to finish also, but I cant for the life of me find them!
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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