Solved

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

Posted on 2006-07-20
12
402 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
  • 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Back Up Your Microsoft Windows Server®

Back up 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.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

809 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