ms access - 'Object Required' to send Email -
i'm trying make function sends email email address in 1 of queries (upcomingbirthday). i've got code in function , in macro autoexec runs when load database.
public function emailsend() dim imsg object dim iconf object dim flds object dim schema string set imsg = createobject("cdo.message") set iconf = createobject("cdo.configuration") set flds = iconf.fields schema = "http://schemas.microsoft.com/cdo/configuration/" flds.item(schema & "sendusing") = cdosendusingport flds.item(schema & "smtpserver") = "smtp.live.com" flds.item(schema & "smtpserverport") = 25 flds.item(schema & "smtpauthenticate") = cdobasic flds.item(schema & "sendusername") = "myemail@hotmail.com" flds.item(schema & "sendpassword") = "mypassword" flds.item(schema & "smtpusessl") = false flds.update imsg call emailsend(upcomingbirthday.[email], "myemail@hotmail.com", "birthday promotion!", "<html>happy birthday! <p> our records indicate you're eligible birthday promotion.</p></html.") set .configuration = iconf .send end set iconf = nothing set imsg = nothing set flds = nothing end function
now when try run code, tells me "run-time error 424 - object required" , highlights line when go debug: call emailsend(upcomingbirthday.[email], "myemail@hotmail.com", "birthday promotion!", etc.. need values column 'email' in query 'upcomingbirthday' , send email them.
if me telling me need fix error that'd great! , if scan code , see if it's fine (as in should work)? thanks! :)
the call emailsend
statement within public function emailsend
problematic. if want assign values properties of imsg
(a cdo.message
object) like
with imsg .to = "recipient@example.com" .from = "myemail@hotmail.com" .subject = "birthday promotion!" '' , on .send end
also, don't know upcomingbirthday
because defined elsewhere.
you might want save bother , use sendemail
function available download here:
Comments
Post a Comment