Reference library needed...

sparx

Morphed Human
Local time
Today, 07:57
Joined
Jul 22, 2002
Messages
80
My code crashes at the following line:

Set iMsg = CreateObject("CDO.Message")

The error message states: ActiveX component can't create object. I'm not sure what to do. I have included all the possible libraries, so now I'm stuck between a rock and a hard place. Anyone have any ideas??

FYI, I'm using Access 2k.


TIA,

Erik
 
We need some more info ...

What are you trying to do?
What type of ActiveX control is this?

Can you included the entire procedure?

Thanks
 
I'm trying to automatically send an e-mail (with MS Outlook) using MS Access without using the DoCmd.SendObject command.
I want no user intervention or anything like that.
 
I believe CDO stands for Collaborated Data Object
 
I simply wanted to send an e-mail out to certain recipients while running an automatic procedure, telling them the their info has been updated. And I didn't want the user who was running the update to have to click anything when sending the e-mail. If there is a way to use the SendObject method without having the user click OK when prompted "An e-mail is being sent on your behalf.", then I'm all ears
 
Try this...
Code:
Private Sub CmdEmail_Click()

      Dim EmailApp, NameSpace, EmailSend As Object
      
      Set EmailApp = CreateObject("Outlook.Application")
      Set NameSpace = EmailApp.getNameSpace("MAPI")
      Set EmailSend = EmailApp.CreateItem(0)
      
      EmailSend.To = "Email Address Here"
      EmailSend.Subject = "Place Subject Here"
      EmailSend.Body = "Dear Someone," & vbCrLf & vbCrLf & "Attached is the latest Update"
      EmailSend.Attachments.Add "C:\Path Here\Supplier Orders.xls"
      EmailSend.Send
      
      Set EmailApp = Nothing
      Set NameSpace = Nothing
      Set EmailSend = Nothing


End Sub

IMO
 
Last edited:
Are you not able to post your code for this procedure?

Try:

DoCmd.SendObject acSendNoObject, , , varYourReceipiant, , , "Your Procedure", "The Procedure has been run.", False

for using the SendObject or use IMO procedure. That will do the trick as well.

Now, the message An e-mail is being sent on your behalf looks like a messge comming from the Exchange Server. I will have to look into that, and IMO procedure might be what you need to use since it is creating an Outlook object. Try them both out and report back.
 
That code works, but it's not really what I'm looking for. The user still needs to click yes in order for the e-mail to be sent, I don't want this, I want the e-mail to be sent without any intervention by the user. Any other ideas??

Thanks,

Erik
 
Here is the code you have been asking for:

Dim mail

Dim TestInput As Variant
Me.TestInput.SetFocus
TestInput = Me.TestInput.Text
Me.MailTo.SetFocus
MailTo = Me.MailTo.Text
Me.MailFrom.SetFocus
MailFrom = Me.MailFrom.Text
Me.MailSubject.SetFocus
MailSubject = Me.MailSubject.Text

Set mail = Nothing

' Send by connecting to port 25 of the SMTP server.
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML

Const cdoSendUsingPort = 2

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.fields

' Set the CDOSYS configuration fields to use port 25 on the SMTP server.

With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
'ToDo: Enter name or IP address of remote SMTP server.
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "" 'smtp server name needs to be put here
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With

' Build HTML for message body.
strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<b> </b></br>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"

' Apply the settings to the message.
With iMsg
Set .Configuration = iConf
.To = MailTo 'ToDo: Enter a valid email address.
.From = MailFrom 'ToDo: Enter a valid email address.
.Subject = MailSubject
.HTMLBody = TestInput
.Send
End With

' Clean up variables.
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
Me.MailFrom = ""
Me.MailTo = ""
Me.MailSubject = ""
Me.TestInput = ""

MsgBox "Mail Sent!"
 
What is the exact content of the prompt the user is having to repond to?
 
I included the attachment of the Microsoft dialog box. It requires the user to click yes in order for the e-mail to be sent
 

Attachments

Now, the message An e-mail is being sent on your behalf looks like a messge comming from the Exchange Server. I will have to look into that, and IMO procedure might be what you need to use since it is creating an Outlook object. Try them both out and report back.

This is a message comming from your Exchange Server. Contact your network people and see about a workaround.

Have you been to the Microsoft web site to investigate?

http://support.microsoft.com/default.aspx?scid=kb;en-us;263084
 
Last edited:
The Outlook security patch is causing this. There are very few ways of getting around it. You can go back to the unpatched version of Outlook and it seems to me that I found a company that made a workaround for it once. I am looking now.
 
Thanks for your help, I'll let you know what the outcome is.
 

Users who are viewing this thread

Back
Top Bottom