TimKestermont
asked on
auto email
Here is the code that I know was successful back when I accepted the answer. Now I can figure out why it's stopping at the docmd line with the email showing in my window.
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)
MyRS.MoveFirst
Do
strTo = MyRS("Email Address")
'Build your message and incorporate the info about customer
strMsg = "Message for Customer " & MyRS("name")
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
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)
MyRS.MoveFirst
Do
strTo = MyRS("Email Address")
'Build your message and incorporate the info about customer
strMsg = "Message for Customer " & MyRS("name")
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
DoCmd.SendObject acSendNoObject, , , strTo, strCC, strBCC, strSubject, strMsg, 0
Dave
Dave
ASKER
Is there a reference in the library that needs to be checked?
Not for SendObject.
You will need to adda refrence to Microsoft DAO object Library to do the other stuff though... If you dont have this refrecened it should have errored on this line Set MyDb = CurrentDb
Dave
You will need to adda refrence to Microsoft DAO object Library to do the other stuff though... If you dont have this refrecened it should have errored on this line Set MyDb = CurrentDb
Dave
these may also be a problem : chaneg them to....
strTo = MyRS("[Email Address]")
and
strMsg = "Message for Customer " & MyRS("[name]")
Dave
strTo = MyRS("[Email Address]")
and
strMsg = "Message for Customer " & MyRS("[name]")
Dave
ASKER
Set MyRS = MyDb.OpenRecordset("Email addresses", dbOpenDynaset) ' This is my tbl name Email addresses
strTo = MyRS("Email Address") this is my email field
strMsg = "Message for Customer " & MyRS("name") this is the "name" of the person
It worked a while back but I didn't have to implement it then.
strTo = MyRS("Email Address") this is my email field
strMsg = "Message for Customer " & MyRS("name") this is the "name" of the person
It worked a while back but I didn't have to implement it then.
Yes, Name is a reserved word, so to get around complications that this causes, try wrapping it in []. Seeing Email Address has a space, also try wrapping this in [] as shown above
Dave
Dave
ASKER
It is now stopping when the email pulls up and sets focus to strTo.
ASKER
Then I try without the spaces by renaming the fields and it stops at the docmd. again.
you sure you got it in the right spot
pls post you new code
Dave
pls post you new code
Dave
ASKER
I can set the spaces in brackets as you mentioned and it's still the same except on name. It will not allow me do just use brackets there. It will usually stop on the strTo in the Docmd. line. or at least that is where it stops and leaves focus on the email. Thanks
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)
MyRS.MoveFirst
Do
strTo = MyRS("EmailAddress")
'Build your message and incorporate the info about customer
strMsg = "This is a test for the auto email " & MyRS("name")
strSubject = "Research Institute"
DoCmd.SendObject acSendNoObject, , "MS-DOS Text (*.txt)", strTo, strCC, strBCC, strSubject, strMsg, 0
MyRS.MoveNext
Loop Until MyRS.EOF
MyRS.Close
MyDB.Close
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)
MyRS.MoveFirst
Do
strTo = MyRS("EmailAddress")
'Build your message and incorporate the info about customer
strMsg = "This is a test for the auto email " & MyRS("name")
strSubject = "Research Institute"
DoCmd.SendObject acSendNoObject, , "MS-DOS Text (*.txt)", strTo, strCC, strBCC, strSubject, strMsg, 0
MyRS.MoveNext
Loop Until MyRS.EOF
MyRS.Close
MyDB.Close
use this!
DoCmd.SendObject acSendNoObject, , , strTo, strCC, strBCC, strSubject, strMsg, 0
DoCmd.SendObject acSendNoObject, , , strTo, strCC, strBCC, strSubject, strMsg, 0
ASKER
This below has the same result. I put a msgbox strTo so that I could see it is passing the emails, so it has to be in the docmd line.
DoCmd.SendObject acSendNoObject, , , strTo, strCC, strBCC, strSubject, strMsg, 0
DoCmd.SendObject acSendNoObject, , , strTo, strCC, strBCC, strSubject, strMsg, 0
Do you have Outlook or Groupwise or something like that installed??
you'll need:
Microsoft Exchange, Microsoft Mail, Microsoft Windows for Workgroups mail, or another electronic mail application that uses the Microsoft Mail Applications Programming Interface (MAPI).
Microsoft Exchange, Microsoft Mail, Microsoft Windows for Workgroups mail, or another electronic mail application that uses the Microsoft Mail Applications Programming Interface (MAPI).
ASKER
Groupwise
ASKER
I'm not for sure about MAPI because this worked fine a couple of months ago.
I use Groupwise too (Version 6.0, think it used to have 5.5 and that worked fine too).
As a test try this
Sub myTest()
Dim sTo As String
sTo = "YourEmailAddressGoesHere! !!"
DoCmd.SendObject acSendNoObject, , , sTo, , , , "This is a test", False
End Sub
Sub myTest()
Dim sTo As String
sTo = "YourEmailAddressGoesHere!
DoCmd.SendObject acSendNoObject, , , sTo, , , , "This is a test", False
End Sub
ASKER
Same break at the docmd.sendobject.
ASKER
Something must of happened somewhere because I used this cold a number of times to demonstrate to my boss that it could be done.
ASKER
Just will not get pass the To field or StrTo.
Just working on another method
Very simple Automation of Groupwise
Sub Email()
Dim oAcct As GroupwareTypeLibrary.Accou nt
Dim oApp As GroupwareTypeLibrary.Appli cation
Dim oMsg As GroupwareTypeLibrary.Messa ge
Dim sRecipient as String
sRecipient = Replace(Replace("david{dot }leahy{at} brisbane{d ot}qld{dot }gov{dot}a u", "{dot}", "."),"{at}","@")
**** Email Address modified ******
Alan Warren
Page Ed (Databases)
************************** **
Set oApp = CreateObject("NovellGroupW areSession ")
Set oAcct = oApp.Login("", "")
Set oMsg = oAcct.MailBox.Messages.Add
oMsg.Subject = "Subject - 0"
oMsg.BodyText = "Body Text"
oMsg.Recipients.Add sRecipient, , 0 '0 for To, 1 for CC, 2 for BCC
oMsg.Send
Set oMsg = Nothing
Set oApp = Nothing
Set oAcct = Nothing
End Sub
Sub Email()
Dim oAcct As GroupwareTypeLibrary.Accou
Dim oApp As GroupwareTypeLibrary.Appli
Dim oMsg As GroupwareTypeLibrary.Messa
Dim sRecipient as String
sRecipient = Replace(Replace("david{dot
**** Email Address modified ******
Alan Warren
Page Ed (Databases)
**************************
Set oApp = CreateObject("NovellGroupW
Set oAcct = oApp.Login("", "")
Set oMsg = oAcct.MailBox.Messages.Add
oMsg.Subject = "Subject - 0"
oMsg.BodyText = "Body Text"
oMsg.Recipients.Add sRecipient, , 0 '0 for To, 1 for CC, 2 for BCC
oMsg.Send
Set oMsg = Nothing
Set oApp = Nothing
Set oAcct = Nothing
End Sub
Add a refrence to Groupware Type library
ASKER
I will let you know tomorrow at work. Thanks
ASKER
The new method works for a specific address. If I type in the address. But would it send to multiple addresses in a database
ASKER
I removed Outlook and now there is no runtime error. If I have 4 email addresses in my db it will pull up 4 email windows and once again not populating the TO or sending the email automatically.
ASKER
Sorry, last comment was incorrect
ASKER
This works on reports-
DoCmd.SendObject acSendReport, "Heyreport", acFormatRTF, strTo, strCC, strBCC, strSubject, strMsg, Val(0)
DoCmd.SendObject acSendReport, "Heyreport", acFormatRTF, strTo, strCC, strBCC, strSubject, strMsg, Val(0)
ASKER
This does not
DoCmd.SendObject acSendNoObject, , "MS-DOS Text (*.txt)", strTo, strCC, strBCC, strSubject, strMsg, Val(0)
DoCmd.SendObject acSendNoObject, , "MS-DOS Text (*.txt)", strTo, strCC, strBCC, strSubject, strMsg, Val(0)
It works fine with Win 2k / Access 97 / Groupwise and Win XP / Access 2003 / Outlook 2003 (Tested at home and at work)
ASKER
Well I don't want to waste anymore of you time. It simply stops at the TO field. I actually posted another question
https://www.experts-exchange.com/questions/21148212/acsendnoobject-isn't-functioning-properly.html
The acSendReport works but not the acSendnoobject. No one has been able to fix or address it adequately. I know the code is suppose to work as I have used it prior. But it's not now.
Thanks for your help.
https://www.experts-exchange.com/questions/21148212/acsendnoobject-isn't-functioning-properly.html
The acSendReport works but not the acSendnoobject. No one has been able to fix or address it adequately. I know the code is suppose to work as I have used it prior. But it's not now.
Thanks for your help.
one last go!
DoCmd.SendObject -1, , ,strTo, strCC, strBCC, strSubject, strMsg, 0
What error does it throw anyway?????
Dave
DoCmd.SendObject -1, , ,strTo, strCC, strBCC, strSubject, strMsg, 0
What error does it throw anyway?????
Dave
ASKER
Hey flavo,
Sorry about the delay. I've got a headache over this...nothing like a stoppage in the work day eh? I did get your groupwise code to work. I can't read it to maybe place a variable in there. But it did work.
There runtime is 2958 reserved error. I looked it up and I was lost overall. I will try the above code.
I want to thank you for the extra effort. I know the code works but you are troubleshooting and I appreciate it a great deal.
Thanks
Sorry about the delay. I've got a headache over this...nothing like a stoppage in the work day eh? I did get your groupwise code to work. I can't read it to maybe place a variable in there. But it did work.
There runtime is 2958 reserved error. I looked it up and I was lost overall. I will try the above code.
I want to thank you for the extra effort. I know the code works but you are troubleshooting and I appreciate it a great deal.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks Alan!
ASKER
Can I do the CurrentDB recordset with this code and pull from the db?'
You sure can mate.
What exactly are you trying to do???
What exactly are you trying to do???
ASKER
I tried to use your code with mine and I sent 2 out of 6 emails with this code. I am trying to send multiple emails to the address's in the DB. Also, could you answer this question on the this link so I can give points to that open question?
https://www.experts-exchange.com/questions/21148212/acsendnoobject-isn't-functioning-properly.html
Dim MyDb As Database
Dim MyRS As Recordset
Dim oAcct As GroupwareTypeLibrary.Accou nt
Dim oApp As GroupwareTypeLibrary.Appli cation
Dim oMsg As GroupwareTypeLibrary.Messa ge
Dim sRecipient As String
Dim strSubject As String
Set oApp = CreateObject("NovellGroupW areSession ")
Set oAcct = oApp.Login("", "")
Set oMsg = oAcct.MailBox.Messages.Add
Set MyDb = CurrentDb
Set MyRS = MyDb.OpenRecordset("Email Addresses", dbOpenDynaset)
MyRS.MoveFirst
Do Until MyRS.EOF
sRecipient = MyRS("EmailAddress")
MyRS.MoveNext
oMsg.Subject = "Subject - 0"
oMsg.BodyText = "Body Text"
oMsg.Recipients.Add sRecipient, , 0 '0 for To, 1 for CC, 2 for BCC
Loop
oMsg.Send
Set oMsg = Nothing
Set oApp = Nothing
Set oAcct = Nothing
https://www.experts-exchange.com/questions/21148212/acsendnoobject-isn't-functioning-properly.html
Dim MyDb As Database
Dim MyRS As Recordset
Dim oAcct As GroupwareTypeLibrary.Accou
Dim oApp As GroupwareTypeLibrary.Appli
Dim oMsg As GroupwareTypeLibrary.Messa
Dim sRecipient As String
Dim strSubject As String
Set oApp = CreateObject("NovellGroupW
Set oAcct = oApp.Login("", "")
Set oMsg = oAcct.MailBox.Messages.Add
Set MyDb = CurrentDb
Set MyRS = MyDb.OpenRecordset("Email Addresses", dbOpenDynaset)
MyRS.MoveFirst
Do Until MyRS.EOF
sRecipient = MyRS("EmailAddress")
MyRS.MoveNext
oMsg.Subject = "Subject - 0"
oMsg.BodyText = "Body Text"
oMsg.Recipients.Add sRecipient, , 0 '0 for To, 1 for CC, 2 for BCC
Loop
oMsg.Send
Set oMsg = Nothing
Set oApp = Nothing
Set oAcct = Nothing
ASKER
https://www.experts-exchange.com/questions/20768220/Access-email.html