Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2006-07-20
12
Medium Priority
?
443 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 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