Solved

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

Posted on 2006-07-20
12
400 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
 
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

707 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

16 Experts available now in Live!

Get 1:1 Help Now