Solved

acsendnoobject isn't functioning properly

Posted on 2004-09-28
58
691 Views
Last Modified: 2011-09-20
This works
DoCmd.SendObject acSendReport, "Heyreport", acFormatRTF, strTo, strCC, strBCC, strSubject, strMsg, Val(0)
This doesn't
DoCmd.SendObject acSendNoObject, , "MS-DOS Text , strTo, strCC, strBCC, strSubject,strMsg, Val(0)

The NoObject line leaves me with an email window up and focus on the TO in the email.  The send report works fine.

Thanks
0
Comment
Question by:TimKestermont
  • 23
  • 22
  • 10
  • +2
58 Comments
 
LVL 26

Expert Comment

by:dannywareham
ID: 12172018
DoCmd.SendObject acSendNoObject, , "MS-DOS Text , strTo, strCC, strBCC, strSubject,strMsg, Val(0)

won't work for two reasons:
Firstly, there's a speech mark
Secondly, the format MS-DOS Text is nt available.

If you type acFORMAT then press ctrl+space, a list of available formats will appear
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 12172030
Scratch that:
acSendNoObject will just create a mail with no attachment - in which case the acFormat command becomes redundant.

0
 

Author Comment

by:TimKestermont
ID: 12172078
This is how it originally started, my mistake
DoCmd.SendObject acSendNoObject, , "MS-DOS Text (*.txt)", strTo, strCC, strBCC, strSubject, strMsg, Val(0)

And is this what you are requesting
DoCmd.SendObject acSendNoObject, , acFormatTXT,strTo, strCC, strBCC, strSubject, strMsg, Val(0)
0
 

Author Comment

by:TimKestermont
ID: 12172115
This is where it stops everytime unless I use acsendreport or table etc..
DoCmd.SendObject acSendNoObject, , strTo, strCC, strBCC, strSubject, strMsg, Val(0)

0
 
LVL 26

Expert Comment

by:dannywareham
ID: 12172134
Rather than val(0), set is as false (to send automatically) and lose the TEXT format (this is the format of the attachment, not the mail)

DoCmd.SendObject acSendNoObject, , , strTo, strCC, strBCC, strSubject, strMsg, False

0
 
LVL 26

Expert Comment

by:dannywareham
ID: 12172178
The command:
DoCmd.SendObject acSendNoObject, , , strTo, strCC, strBCC, strSubject, strMsg, False

Works on mine no probs...
What it may be in your case is if strTo, strCC, or strBCC are not valid addresses, in SMTP format (ie...   Someone@somewhere.com)
0
 

Author Comment

by:TimKestermont
ID: 12172227
I just don't know because the reports and tables etc...run fine.  Only when I use the acsendnoobject.  I am using Groupwise as well.  But the emails blast off fine when reports and tables are being sent.  Don't get it
0
 

Author Comment

by:TimKestermont
ID: 12172261
Here is the complete code

Dim MyDb As Database
Dim MyRS As Recordset
Dim strTo As String
Dim strCC As String
Dim strBCC As String
Dim strMsg As String
Dim strSubject As String
Dim x As Variant
Set MyDb = CurrentDb
Set MyRS = MyDb.OpenRecordset("Email addresses", dbOpenDynaset)THIS IS THE TABLE

MyRS.MoveFirst
Do

strTo = MyRS("Email Address")THIS IS THE EMAIL FIELD
strMsg = "Message for Customer " & MyRS("name") "THIS IS THE NAME FIELD"
strSubject = "Billing Information Notice"
DoCmd.SendObject acSendNoObject, , "MS-DOS Text (*.txt)", strTo, strCC, strBCC, strSubject, strMsg, Val(0)
MyRS.MoveNext
Loop Until MyRS.EOF
MyRS.Close
MyDb.Close
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 12172273
This is exactly what I have in my working example:

DoCmd.SendObject acSendNoObject, , , "daniel@some.com", , , , , Val(0)
**** Email address edited *****
Alan Warren
Page Ed (databases)
*************************
Do you have any broken references?
Check that you have Outlook 9.0 (or 10.0)
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 12172310
Your code looks fine (providing the CAPS bits are prefixed with an apostrophy...)

Try losing the loop and testing just the send option first.
Then build up from that to the loop
You may also want to include some error handling in here too.
0
 

Author Comment

by:TimKestermont
ID: 12172484
I am not using outlook, but GroupWise

I lost the loop,  even with a simple DoCmd.SendObject acSendNoObject, , , Me.emailaddress it stops with the email open and the TO has focus

It has something to do with the acSendNoObject.  I tried your code the very same text and stopped with the email box open focus on the To.
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 12172526
OK.
This may be the problem.
Access's built in command is for Outlook.
I've not used GroupWise myself, so can't offer any of my own advice.
Give me a second to do some hunting....

:-)
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 12172562
OK:
This is from an old post:

I've gotten it (sendObject) to work with Access 97 and GroupWise version 5.2.  It's a bit of a pain in the neck, but here goes.  I think that generally you must get the SendObject to find GroupWise's mapi.dll.  This seems to work best when the last email program installed was GroupWise (there's probably an easier way to do that part.)  But the other part is that I needed was a kludgy utility from MS called the Form Switching utility (go to Knowledgebase and search Outlook for form switching -see the article and can download it see article #143477).  It's designed to switch between the slightly different Outlook and Exchange client form, but you need it to be set for Outlook for the sendobject to work with GroupWise.  I think that I found that last little nugget on the Novell knowledgebase (see article #2919555 for some other details).
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 12172586
Another suggestion is to include "Do Events" in your code to slow it down and let GroupWise catch up.
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 12172613
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12172774
Tim,

I would highly suggest avoiding SendObject. As you've discovered, it is buggy and unreliable. In addition to Danny's link, you might want to take a look here:
http://www.granite.ab.ca/access/email/novellgroupwise.htm
0
 

Author Comment

by:TimKestermont
ID: 12172886
what would you suggest in the auto send email using a form and button access db
0
 
LVL 34

Expert Comment

by:flavo
ID: 12175035
docmd.sendobject works with Groupwise 5.5 and 6.0 (Have it at work)

Tim,

Could you get the Groupwise Automation code i posted  to work???
0
 

Author Comment

by:TimKestermont
ID: 12176656
I have GroupWise 6.5 on our network.  I know it's got to be something small but hidden.  It use to work like I said, as I stated in the other question, the GW code worked fine but wouldn't autosend nor could I figure out how to put the variables.

Thanks
0
 
LVL 34

Expert Comment

by:flavo
ID: 12176938
I dont always..

can you take a look here Alan

http://www.experts-exchange.com/Databases/MS_Access/Q_21146965.html

posted Date: 09/28/2004 08:49AM EST

Dave
0
 
LVL 26

Expert Comment

by:Alan Warren
ID: 12177475
Hi Dave

you want I should fix that post with your cool replace string for you?

Alan
0
 
LVL 34

Expert Comment

by:flavo
ID: 12185163
Tim

Set MyDb = CurrentDb
Set MyRS = MyDb.OpenRecordset("Email Addresses", dbOpenDynaset)
MyRS.MoveFirst
Do Until MyRS.EOF
sRecipient = sRecipient & ";" & MyRS("EmailAddress")

MyRS.MoveNext

Dave
0
 

Author Comment

by:TimKestermont
ID: 12186745
Thanks, I will try and give it a whirl tomorrow between backup and webstuff and everything else..I'm sure you know what I mean.  How does that read.  sRecipient & ";" & MyRS("EmailAddress")

In the Do until but where should I put the Loop?  I noticed if I put it  after the oMsg.send  I get the runtime error.  But before is where I had it. ""THIS IS YOUR CODE BELOW" by the way.

Dim oAcct As GroupwareTypeLibrary.Account
Dim oApp As GroupwareTypeLibrary.Application
Dim oMsg As GroupwareTypeLibrary.Message

'Create a new instance of GW for us to use in VBA
Set oApp = CreateObject("NovellGroupWareSession")
'Log in - note, you you dont have GW logged in, it will prompt with the usual login screen
' you can also use Set oAcct = oApp.Login("userName", "Password") if you want
Set oAcct = oApp.Login("", "")

'create a new email message for us to use
Set oMsg = oAcct.MailBox.Messages.Add

'as above
oMsg.Subject = "Subject - 0"
oMsg.BodyText = "Body Text"
oMsg.Recipients.Add sRecipient, , 0   '0 for To, 1 for CC, 2 for BCC
oMsg.Send

'clean up our variables
Set oMsg = Nothing
Set oApp = Nothing
Set oAcct = Nothing

0
 
LVL 34

Expert Comment

by:flavo
ID: 12186760
Tim,

Dim oAcct As GroupwareTypeLibrary.Account
Dim oApp As GroupwareTypeLibrary.Application
Dim oMsg As GroupwareTypeLibrary.Message

'Create a new instance of GW for us to use in VBA
Set oApp = CreateObject("NovellGroupWareSession")
'Log in - note, you you dont have GW logged in, it will prompt with the usual login screen
' you can also use Set oAcct = oApp.Login("userName", "Password") if you want
Set oAcct = oApp.Login("", "")

'create a new email message for us to use
Set oMsg = oAcct.MailBox.Messages.Add

'as above
oMsg.Subject = "Subject - 0"
oMsg.BodyText = "Body Text"

Set MyDb = CurrentDb
Set MyRS = MyDb.OpenRecordset("Email Addresses", dbOpenDynaset)
MyRS.MoveFirst
Do Until MyRS.EOF
sRecipient = sRecipient & ";" & MyRS("EmailAddress")

MyRS.MoveNext

oMsg.Recipients.Add sRecipient, , 0  
oMsg.Send

'clean up our variables
Set oMsg = Nothing
Set oApp = Nothing
Set oAcct = Nothing


I have assumed they are all To, not CC or BCC

Dave
0
 
LVL 34

Expert Comment

by:flavo
ID: 12186790
Oopps, forogt comments for you

'loop until we reach the end of the recordset
Do Until MyRS.EOF

'Append the records email address to the current string of Emails
'for example on the first time through the loop sRecipient would look like
' "someEmail@somewhere.com;"
' after the second loop with would look like
' "someEmail@somewhere.com;someOtherEmail@somewhereElse.com;"
sRecipient = sRecipient & ";" & MyRS("EmailAddress")

'move to the next record
MyRS.MoveNext

'should also add this line in tooo

'this line "chops" off the last ; that we dont really want
sRecipient = Left(sRecipient, Len(sRecipient) -1)
0
 
LVL 34

Expert Comment

by:flavo
ID: 12186793
New code

Dim oAcct As GroupwareTypeLibrary.Account
Dim oApp As GroupwareTypeLibrary.Application
Dim oMsg As GroupwareTypeLibrary.Message

'Create a new instance of GW for us to use in VBA
Set oApp = CreateObject("NovellGroupWareSession")
'Log in - note, you you dont have GW logged in, it will prompt with the usual login screen
' you can also use Set oAcct = oApp.Login("userName", "Password") if you want
Set oAcct = oApp.Login("", "")

'create a new email message for us to use
Set oMsg = oAcct.MailBox.Messages.Add

'as above
oMsg.Subject = "Subject - 0"
oMsg.BodyText = "Body Text"

Set MyDb = CurrentDb
Set MyRS = MyDb.OpenRecordset("Email Addresses", dbOpenDynaset)
MyRS.MoveFirst
Do Until MyRS.EOF
sRecipient = sRecipient & ";" & MyRS("EmailAddress")
MyRS.MoveNext

sRecipient = Left(sRecipient, Len(sRecipient) -1)
oMsg.Recipients.Add sRecipient, , 0  
oMsg.Send

'clean up our variables
Set oMsg = Nothing
Set oApp = Nothing
Set oAcct = Nothing
0
 

Author Comment

by:TimKestermont
ID: 12190565
One more question about the code.  do until is there but the Loop is not.   If I place the loop after the oMsg.Send I get a runtime error, if I put it just after the oMsg.rec line I receive the mail dameon response in the email about he the attachment of subject-0.  This response is because it cuts of the last character-

Tested Loop above the sRecipient = Left(sRecipient, Len(sRecipient) -1)
result- 1 email sent and no errors-  other than I have more than 1 email that should of went.

Tested Loop after- sRecipient = Left(sRecipient, Len(sRecipient) -1)
result Mail Dameon-  it cut off the domain by one letter jack@home.or...  

I rem'd the  sRecipient = Left(sRecipient, Len(sRecipient) -1)
result-1 email sent and no errors-  other than I have more than 1 email that should of went.

I am close to letting this go.  Let me know how you feel about it.



0
 
LVL 34

Expert Comment

by:flavo
ID: 12193688
oh yeah forgot the loop.....

(Cant copy and paste)

Dim oAcct As GroupwareTypeLibrary.Account
Dim oApp As GroupwareTypeLibrary.Application
Dim oMsg As GroupwareTypeLibrary.Message

'Create a new instance of GW for us to use in VBA
Set oApp = CreateObject("NovellGroupWareSession")
'Log in - note, you you dont have GW logged in, it will prompt with the usual login screen
' you can also use Set oAcct = oApp.Login("userName", "Password") if you want
Set oAcct = oApp.Login("", "")

'create a new email message for us to use
Set oMsg = oAcct.MailBox.Messages.Add

'as above
oMsg.Subject = "Subject - 0"
oMsg.BodyText = "Body Text"

Set MyDb = CurrentDb
Set MyRS = MyDb.OpenRecordset("Email Addresses", dbOpenDynaset)
MyRS.MoveFirst
Do Until MyRS.EOF
sRecipient = sRecipient & ";" & MyRS("EmailAddress")
MyRS.MoveNext
Loop

If Len(sRecipient) > 1 then
   'this if statement is used to stop it throwing an error if there were no email addresses
   sRecipient = Left(sRecipient, Len(sRecipient) -1)
end if

oMsg.Recipients.Add sRecipient, , 0  
oMsg.Send

'clean up our variables
Set oMsg = Nothing
Set oApp = Nothing
Set oAcct = Nothing
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:TimKestermont
ID: 12193789
I needed a good laugh today.  Thanks...I will try it.
0
 

Author Comment

by:TimKestermont
ID: 12196725
Are you able to send multiple emails?  I am only able to do one.
0
 
LVL 34

Expert Comment

by:flavo
ID: 12196825
ahh... mustnt be able to to that

use this

Dim oAcct As GroupwareTypeLibrary.Account
Dim oApp As GroupwareTypeLibrary.Application
Dim oMsg As GroupwareTypeLibrary.Message

'Create a new instance of GW for us to use in VBA
Set oApp = CreateObject("NovellGroupWareSession")
'Log in - note, you you dont have GW logged in, it will prompt with the usual login screen
' you can also use Set oAcct = oApp.Login("userName", "Password") if you want
Set oAcct = oApp.Login("", "")

'create a new email message for us to use
Set oMsg = oAcct.MailBox.Messages.Add

'as above
oMsg.Subject = "Subject - 0"
oMsg.BodyText = "Body Text"

Set MyDb = CurrentDb
Set MyRS = MyDb.OpenRecordset("Email Addresses", dbOpenDynaset)
MyRS.MoveFirst
   
  Do Until MyRS.EOF
         oMsg.Recipients.Add MyRS("EmailAddress"), , 0
         MyRS.MoveNext
   Loop

oMsg.Send

'clean up our variables
Set oMsg = Nothing
Set oApp = Nothing
Set oAcct = Nothing
0
 

Author Comment

by:TimKestermont
ID: 12196852
Invalid argument was passed in the function call

oMsg.Recipients.Add MyRS("EmailAddress"), , 0
0
 

Author Comment

by:TimKestermont
ID: 12196884
If I step through on the old code docmdsend etc.... when I hover over the strTo it has the email address in it.
0
 
LVL 34

Expert Comment

by:flavo
ID: 12197004
oMsg.Recipients.Add MyRS("EmailAddress")
0
 

Author Comment

by:TimKestermont
ID: 12197122
Doesn't work
I give...I'm done, can't take it anymore...I'll just say I can only do one email at a time.  

Thanks
0
 
LVL 34

Expert Comment

by:flavo
ID: 12197171
rubish! i can be done

 I have an app that does almost exactly the same thing!
0
 
LVL 34

Accepted Solution

by:
flavo earned 500 total points
ID: 12197182
Tested and worked a treat

need to add a .Value  after myRs("EmailAddress")


Dim oAcct As GroupwareTypeLibrary.Account
Dim oApp As GroupwareTypeLibrary.Application
Dim oMsg As GroupwareTypeLibrary.Message
Dim Mydb As DAO.Database
Dim myRs As DAO.Recordset
'Create a new instance of GW for us to use in VBA
Set oApp = CreateObject("NovellGroupWareSession")
'Log in - note, you you dont have GW logged in, it will prompt with the usual login screen
' you can also use Set oAcct = oApp.Login("userName", "Password") if you want
Set oAcct = oApp.Login("", "")

'create a new email message for us to use
Set oMsg = oAcct.MailBox.Messages.Add

'as above
oMsg.Subject = "Subject - 0"
oMsg.BodyText = "Body Text"

Set Mydb = CurrentDb
Set myRs = Mydb.OpenRecordset("Email Addresses", dbOpenDynaset)
myRs.MoveFirst
   
  Do Until myRs.EOF
         oMsg.Recipients.Add myRs("EmailAddress").Value
         myRs.MoveNext
   Loop

oMsg.Send

'clean up our variables
Set oMsg = Nothing
Set oApp = Nothing
Set oAcct = Nothing
0
 

Author Comment

by:TimKestermont
ID: 12197205
So with one click you send multiple emails ?  I am still just sending one.\\

My tbl is Email Addresses and my field is emailaddress and when I f8 through the loop i get every email address but it still only sends one.
0
 
LVL 34

Expert Comment

by:flavo
ID: 12197215
Tim,

Can you post your email address in a non-spam way  (ie Tim{at}somewhere DOT com)

Ill send you an email with my app.

Dave
0
 
LVL 34

Expert Comment

by:flavo
ID: 12197312
do you actually have diferent email addresses?  GW is pritty smart, and if you try to add the same email address in 2 or more times, it still only sends it once
0
 

Author Comment

by:TimKestermont
ID: 12197330
yes,  I have two hotmail accounts for testing.  So I should get 3 emails.  But I only get one.
0
 

Author Comment

by:TimKestermont
ID: 12197341
post{seed&less&than&what""hotmaildotcom}4Flavo
0
 
LVL 34

Expert Comment

by:flavo
ID: 12197362
geeee.. i hope i get it right, i can hardly work it out...
0
 
LVL 34

Expert Comment

by:flavo
ID: 12197367
the email has made it to both my test emails
0
 
LVL 34

Expert Comment

by:flavo
ID: 12197371
maybe the hotmail servers are down????
0
 

Author Comment

by:TimKestermont
ID: 12197382
wait a sec b4 you send....I may have found the issue
0
 

Author Comment

by:TimKestermont
ID: 12197402
Excellent- This is working!!!!! Don't get it as far as why it wasn't prior.  I think my hotmail accounts were full or something.  But I opened a couple of office accounts through my VPN and it works great!  You rock man...and really thanks a tremendous amount for hanging with me in my stressful hour!  Now I can move on..
0
 

Author Comment

by:TimKestermont
ID: 12197406
Yes I did get your email...no attachment or anything like that just a strange message from hotmail
0
 
LVL 34

Expert Comment

by:flavo
ID: 12197408
Glad its all working now!


>>  I think my hotmail accounts were full or something

Damn spammers!

dave
0
 
LVL 34

Expert Comment

by:flavo
ID: 12197412
It should have said

This email was sent at1/10/2004 3:03:28 PM
0
 

Author Comment

by:TimKestermont
ID: 12197420
it's 21:20AM here ...Now I can sleep!  Thanks
0
 
LVL 34

Expert Comment

by:flavo
ID: 12197421
very easy to add attachements

all you need to do (for example) is to add

oMsg.Attachments.Add "c:\someFileToAttach.txt"


just bfore you send - just before this line  ->     oMsg.Send

Dave
0
 
LVL 34

Expert Comment

by:flavo
ID: 12197424
Its 3:20pm on Friday afternoon, nearly time to hit the pub for some tastey beers

Later!

Good luck!

Dave
0
 

Author Comment

by:TimKestermont
ID: 12199798
Thanks for the attachment infor...I am very appreciative of your help.  Where are you?  Like Hawaii?
0
 
LVL 34

Expert Comment

by:flavo
ID: 12200617
Australia mate.. in Brisbane
0
 
LVL 34

Expert Comment

by:flavo
ID: 12200840
like you its now 1:15AM (Saturday) :-)
0
 
LVL 34

Expert Comment

by:flavo
ID: 12200848
>> like you

Like you -> as in, for some reason i decide to stay up and visit EE....
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

746 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

18 Experts available now in Live!

Get 1:1 Help Now