Link to home
Start Free TrialLog in
Avatar of TimKestermont
TimKestermont

asked on

acsendnoobject isn't functioning properly

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
Avatar of dannywareham
dannywareham
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Scratch that:
acSendNoObject will just create a mail with no attachment - in which case the acFormat command becomes redundant.

Avatar of TimKestermont
TimKestermont

ASKER

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)
This is where it stops everytime unless I use acsendreport or table etc..
DoCmd.SendObject acSendNoObject, , strTo, strCC, strBCC, strSubject, strMsg, Val(0)

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

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)
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
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
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)
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.
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.
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....

:-)
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).
Another suggestion is to include "Do Events" in your code to slow it down and let GroupWise catch up.
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
what would you suggest in the auto send email using a form and button access db
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???
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
I dont always..

can you take a look here Alan

https://www.experts-exchange.com/questions/21146965/auto-email.html

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

Dave
Hi Dave

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

Alan
Tim

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

MyRS.MoveNext

Dave
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

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
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)
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
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.



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
I needed a good laugh today.  Thanks...I will try it.
Are you able to send multiple emails?  I am only able to do one.
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
Invalid argument was passed in the function call

oMsg.Recipients.Add MyRS("EmailAddress"), , 0
If I step through on the old code docmdsend etc.... when I hover over the strTo it has the email address in it.
oMsg.Recipients.Add MyRS("EmailAddress")
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
rubish! i can be done

 I have an app that does almost exactly the same thing!
ASKER CERTIFIED SOLUTION
Avatar of flavo
flavo
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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
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
yes,  I have two hotmail accounts for testing.  So I should get 3 emails.  But I only get one.
post{seed&less&than&what""hotmaildotcom}4Flavo
geeee.. i hope i get it right, i can hardly work it out...
the email has made it to both my test emails
maybe the hotmail servers are down????
wait a sec b4 you send....I may have found the issue
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..
Yes I did get your email...no attachment or anything like that just a strange message from hotmail
Glad its all working now!


>>  I think my hotmail accounts were full or something

Damn spammers!

dave
It should have said

This email was sent at1/10/2004 3:03:28 PM
it's 21:20AM here ...Now I can sleep!  Thanks
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
Its 3:20pm on Friday afternoon, nearly time to hit the pub for some tastey beers

Later!

Good luck!

Dave
Thanks for the attachment infor...I am very appreciative of your help.  Where are you?  Like Hawaii?
Australia mate.. in Brisbane
like you its now 1:15AM (Saturday) :-)
>> like you

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