CDO & Outlook 2002 problem

Status
Not open for further replies.

Akula

Well-known member
17,428
Ok, previously I had a thread regarding getting a warning message about "this program is using the Address book, would you like it to allow access" etc. Well the suggestion was to use CDO. Unfortunately CDO is coming up with the same problem. What is wrong with this code?

code:<HR>
Code:
Public Function iSendEmail()
    
    Dim objsession As Object
    Dim objmessage As Object
    Dim objrecipient As Object
    
    'Create the Session Object
    Set objsession = CreateObject("mapi.session")
    
    'This must be a valid Logon name, based on the computer it is installed on.
    objsession.Logon profileName:="ALocalAdmin"
    
    'Add a new message object to the Outbox
    Set objmessage = objsession.Outbox.Messages.Add
    
    'Set the properties of the message object
    objmessage.Subject = "This is a test."
    objmessage.Text = "This is the message text."
    
    'Add a recipient object to the objmessage.recipients.add
    Set objrecipient = objmessage.Recipients.Add
    
    'Set the properties fo the recipient object
    objrecipient.Name = "user@somewhere.com"
    
    'Type can be ActMsgTo, mapito, or Cdoto for different cdo versions
    objrecipient.Type = mapiTo
    objrecipient.Resolve
    
    'Send the message
    objmessage.Send showDialog:=False
    MsgBox "Message sent successfully"
    
    'logoff using the session object
    objsession.Logoff
    
    Set objsession = Nothing
    Set objmessage = Nothing
    Set objrecipient = Nothing
 
End Function
 
I think you're not going to be able to get around that message - because of the large number of worms that spread using this method.

I think they were talking about using CDO server-side. You should be able to create a mailbox and create an Agent that can distribute the message. Take a look at cdolive.com - not the best site, but it's a good start.
 

dhopton

Ars Tribunus Militum
2,009
jack ass-joe is correct. You cannot get rid of this message with Outlook 2000 SP2 or greater. It's all because of those worms spreading via it. Look at what happens any time you try to automate Outlook from even IE by clicking a link... it pops up. it's sad that such functionality has been abused, but hey. :(

If you use it on the server side (either in an ASP page or an application), then all is fine. you may want to look at the method that is used to send the mail - eg, either directly via SMTP or via exchange (in this case the item is saved in the mailboxes "sent items").

There *may* be a registry setting to turn this off, and now I think about it, there maybe an option in the outlook settings to change this behaviour. I'd chack but this pooter doesnt have outlook on it.
 
Status
Not open for further replies.