Russell Grice
Registered User.
- Local time
- Today, 16:39
- Joined
- May 22, 2002
- Messages
- 10
Hi, Im pretty new to VBA development and would like a little help !
Trying to send an email after a button on a form is pressed. Have a module with email code in it:
Set MyOutlook = New Outlook.Application
Set MyMail = MyOutlook.CreateItem(olMailItem)
MyMail.SentOnBehalfOfName = strFrom
MyMail.To = strTo
MyMail.CC = strCC
MyMail.Subject = strSubject
MyMail.Body = strBody
MyMail.Send
This works fine but I get the confirmation message ' A program is trying to send an email on your behalf...' when each email is sent. Not very useful.
So I want to try using CDONTS to send the email.
I have some code which I nicked from an ASP pages which I send CDONTS emails from.
Set newmail = CreateObject("CDONTS.NewMail")
newmail.From = "rgrice@cornwall.gov.uk"
newmail.To = "ktwalker@cornwall.gov.uk"
newmail.CC = "rgrice@cornwall.gov.uk"
newmail.BCC = "cchirgwin@cornwall.gov.uk"
newmail.Body = strBody
newmail.Subject = "TEST Message"
newmail.Send
Set newmail = Nothing
Unfortunatly Im getting 'Active X Control cannot create object' I know its probably something very simple...!
Cheers in advance
Russell
Trying to send an email after a button on a form is pressed. Have a module with email code in it:
Set MyOutlook = New Outlook.Application
Set MyMail = MyOutlook.CreateItem(olMailItem)
MyMail.SentOnBehalfOfName = strFrom
MyMail.To = strTo
MyMail.CC = strCC
MyMail.Subject = strSubject
MyMail.Body = strBody
MyMail.Send
This works fine but I get the confirmation message ' A program is trying to send an email on your behalf...' when each email is sent. Not very useful.
So I want to try using CDONTS to send the email.
I have some code which I nicked from an ASP pages which I send CDONTS emails from.
Set newmail = CreateObject("CDONTS.NewMail")
newmail.From = "rgrice@cornwall.gov.uk"
newmail.To = "ktwalker@cornwall.gov.uk"
newmail.CC = "rgrice@cornwall.gov.uk"
newmail.BCC = "cchirgwin@cornwall.gov.uk"
newmail.Body = strBody
newmail.Subject = "TEST Message"
newmail.Send
Set newmail = Nothing
Unfortunatly Im getting 'Active X Control cannot create object' I know its probably something very simple...!
Cheers in advance
Russell