By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,079 Members | 1,700 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,079 IT Pros & Developers. It's quick & easy.

Automating Emails using CDO

P: 5
Hi,

I am using Access in Office 2003 to try to automate messaging people in my organisation after a certain period has passed. I have managed to do this fine with what little knowledge I have, apart from the fact using Outlook creates a security confirmation message, which ruins the whole automation process. I cannot really bypass this.

I read that using a CDO message would not create this security alert. However, I am not sure exactly how to connect to my server, or whether it would allow me to do this, I have tried to talk to IS, and they haven't got back to me.

I've got various code examples from the internet and when I run them it asks about connection to the server, as below;
Expand|Select|Wrap|Line Numbers
  1. Public Function CDOMail_Click()
  2.  
  3. Set cdoConfig = CreateObject("CDO.Configuration")
  4.  
  5.     With cdoConfig.Fields
  6.         .Item(cdoSendUsingMethod) = cdoSendUsingPort
  7.         .Item(cdoSMTPServer) = "<server name>" 'My server name from Outlook is D1EXC004
  8.         .Update
  9.     End With
  10.  
  11.     Set cdoMessage = CreateObject("CDO.Message")
  12.  
  13.     With cdoMessage
  14.         Set .Configuration = cdoConfig
  15.         .From = "peter.martin@rpa.gsi.gov.uk"
  16.         .To = "peter.martin@rpa.gsi.gov.uk"
  17.         .Subject = "Sample CDO Message"
  18.         .TextBody = "This is a test for CDO.message"
  19.         .Send
  20.     End With
  21.  
  22.     Set cdoMessage = Nothing
  23.     Set cdoConfig = Nothing
  24.  
  25. End Function
  26.  
Any advice as to how to connect to the server for CDO messages would be appreciated
May 22 '07 #1
Share this Question
Share on Google+
8 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
I am using Access in Office 2003 to try to automate messaging people in my organisation after a certain period has passed. I have managed to do this fine with what little knowledge I have, apart from the fact using Outlook creates a security confirmation message, which ruins the whole automation process. I cannot really bypass this.
This is an outlook setting and can be turned off in outlook. This would probably not be allowed by your company for security reasons though.

I read that using a CDO message would not create this security alert. However, I am not sure exactly how to connect to my server, or whether it would allow me to do this, I have tried to talk to IS, and they haven't got back to me.

I've got various code examples from the internet and when I run them it asks about connection to the server, as below;
Expand|Select|Wrap|Line Numbers
  1. Public Function CDOMail_Click()
  2.  
  3. Set cdoConfig = CreateObject("CDO.Configuration")
  4.  
  5.     With cdoConfig.Fields
  6.         .Item(cdoSendUsingMethod) = cdoSendUsingPort
  7.         .Item(cdoSMTPServer) = "<server name>" 'My server name from Outlook is D1EXC004
  8.         .Update
  9.     End With
  10.  
  11.     Set cdoMessage = CreateObject("CDO.Message")
  12.  
  13.     With cdoMessage
  14.         Set .Configuration = cdoConfig
  15.         .From = "peter.martin@rpa.gsi.gov.uk"
  16.         .To = "peter.martin@rpa.gsi.gov.uk"
  17.         .Subject = "Sample CDO Message"
  18.         .TextBody = "This is a test for CDO.message"
  19.         .Send
  20.     End With
  21.  
  22.     Set cdoMessage = Nothing
  23.     Set cdoConfig = Nothing
  24.  
  25. End Function
  26.  
Any advice as to how to connect to the server for CDO messages would be appreciated
I don't use CDO so I will leave this for someone else to answer.
May 25 '07 #2

JConsulting
Expert 100+
P: 603
Hi,

I am using Access in Office 2003 to try to automate messaging people in my organisation after a certain period has passed. I have managed to do this fine with what little knowledge I have, apart from the fact using Outlook creates a security confirmation message, which ruins the whole automation process. I cannot really bypass this.

I read that using a CDO message would not create this security alert. However, I am not sure exactly how to connect to my server, or whether it would allow me to do this, I have tried to talk to IS, and they haven't got back to me.

I've got various code examples from the internet and when I run them it asks about connection to the server, as below;

Public Function CDOMail_Click()

Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "<server name>" 'My server name from Outlook is D1EXC004
.Update
End With

Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
Set .Configuration = cdoConfig
.From = "peter.martin@rpa.gsi.gov.uk"
.To = "peter.martin@rpa.gsi.gov.uk"
.Subject = "Sample CDO Message"
.TextBody = "This is a test for CDO.message"
.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing

End Function

Any advice as to how to connect to the server for CDO messages would be appreciated

here is the code I use to send mail using CDO

Expand|Select|Wrap|Line Numbers
  1. Public Function SendEmailCDO(ByVal strTo As String, _
  2.                           ByVal strMessage As String, _
  3.                           ByVal strSubject As String, _
  4.                           Optional ByVal strAttach As String)
  5.     Dim objEmail As Object
  6.     On Error Resume Next
  7.     Set objEmail = CreateObject("CDO.Message")
  8.     '**** email address of sender
  9.     objEmail.FROM = "fred@smith.com"
  10.     objEmail.To = strTo
  11.     objEmail.Subject = strSubject
  12.     objEmail.TextBody = strMessage
  13.     If strAttach <> "" Then objEmail.AddAttachment strAttach
  14.     objEmail.Configuration.Fields.Item( "http://schemas.microsoft.com/cdo/configuration/sendusing")=2
  15.     '*** smtp.xxx.com - here u enter your smtp server name, whatever that is
  16.    objEmail.Configuration.Fields.Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.xx.com"
  17.     objEmail.Configuration.Fields.Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
  18.     objEmail.Configuration.Fields.Update
  19.     objEmail.Send
  20.     If err.Number <> 0 Then
  21.         MsgBox "Error in sending. " & err.Description
  22.     Else
  23.         MsgBox "Sent"   'remove this if u dont want confirmation
  24.     End If
  25.     Set objEmail = Nothing
  26.  
  27. End Function
  28.  
let me know if you need any followup.
J
May 26 '07 #3

JodiPhillips
P: 26
J can CDO be used to open a .oft?
May 29 '07 #4

JConsulting
Expert 100+
P: 603
J can CDO be used to open a .oft?
.oft?

not sure what that is.
May 29 '07 #5

JodiPhillips
P: 26
.oft?

not sure what that is.
.oft is an Outlook file template. Not sure if you can combine a CDO message and open a template file at the same time? I'm looking at doing this but not sure if I'm going about it the right way.

Edit: typos and sentence restructure
May 29 '07 #6

JodiPhillips
P: 26
.oft is an Outlook file template. Not sure if you can combine a CDO message and open a template file at the same time? I'm looking at doing this but not sure if I'm going about it the right way.

Edit: typos and sentence restructure
Gawd! I apologise sincerely for this "stupid" and "ignorant" question!! Have since done some other reading and now realise that this is wayyyyyy off the planet.

Jodi
Jun 12 '07 #7

P: 1
[quote=mmccarthy]This is an outlook setting and can be turned off in outlook. This would probably not be allowed by your company for security reasons though.

I am attempting this same process, and have the access rights to turn this setting off if I knew where to find it :). Can you tell me how to turn the prompt off in Outlook? Thanks!!!
Jun 14 '07 #8

MMcCarthy
Expert Mod 10K+
P: 14,534
This is an outlook setting and can be turned off in outlook. This would probably not be allowed by your company for security reasons though.
I am attempting this same process, and have the access rights to turn this setting off if I knew where to find it :). Can you tell me how to turn the prompt off in Outlook? Thanks!!!
In Outlook 2000 or earlier go to options and under the security tab click on Attachment Security. Be careful though as this disables all attachment security.

In Outlook 2003 or later you will need to use automation VBA code as follows

Expand|Select|Wrap|Line Numbers
  1.  
  2. OlSecurityManager.ConnectTo OutlookApp
  3. OlSecurityManager.DisableOOMWarnings = True
  4. On Error Goto Finally 
  5.  
  6. '... send your mails here ... 
  7.  
  8. Finally: OlSecurityManager.DisableOOMWarnings = False 
  9.  
Jun 14 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.