[AccessD] Popup Form

MartyConnelly martyconnelly at shaw.ca
Sun Aug 5 16:20:09 CDT 2007


Here is my test code for CDO along with some notes

2 things to note with this method

This code wont run exactly unless you are on cable modem or inside a LAN
or maybe VPN and signed on in whatever is your domain,
your cable modem is a node in your ISP domain.  So it will probably fail
on dial-up modems. I haven't really tested this.

If you type in an  illegal or wrong smtp address here, program will run 
for 30-
60 seconds and finally give transport error. So it isn't really hung.

'The example code is using CDOSYS (CDO for Windows 2000 or XP).
'I dont think I would want to go back to CDONTS for earlier systems
'It does not depend on MAPI or CDO or Outlook
'It does not use your mailbox to send email.
' So you can send mail without a mail program or mail account
' This code builds the message and drops it into a pickup directory,
' and the SMTP service running on the machine
' picks it up and send it out to the internet.

'So why use CDO code instead of Outlook automation or
Application.SendMail in VBA.
' It doesn't matter what Mail program you are using (It uses the
SMTP server).
' It doesn't matter what Office version you are using.
' supposedly you can send an object or file in the body of the mail
(some mail programs can't do this)
' haven't verified this
' You can send any file attachment you like.
' No Outlook Security warning so no need for Redemption

' You probably wont have your mail server full expanded smtp address
'If you go into netscape mail or outlook and look for the smtp name
'It will look like mine, "shawmail" or "shawnews" this dns resolves
'to "shawmail.cg.shawcable.net" CDO doesn't resolve this short name
so
'The quickest way to get this actual address without using registry
et al.
'is run cmd and ping "shawmail" to return full qualified smtp
address.
'This code wont run exactly unless you are on cable and signed on in
the Shaw or whatever is your domain, your cable modem is a node in
their domain

Sub SendCDO()
' This example use late binding of CDOSys, you don't have to set a
reference
' You must be online to net when you run the sub
' You must be running WinXP or Win2000
Dim cdoMessage As Object
Dim objCDOMail As Object
Dim strschema As String
On Error GoTo ErrorHandler ' Enable error-handling routine.
'
Set cdoMessage = CreateObject("CDO.Message")
Set objCDOMail = CreateObject("CDO.Configuration")
strschema = "http://schemas.microsoft.com/cdo/configuration/"
objCDOMail.Load -1 ' CDO Source Default
'If you have illegal or wrong smtp address here it will run for 30-
60 seconds and finally give transport error
With objCDOMail.Fields
.Item(strschema & "sendusing") = 2 ' cdoSendUsingPort
.Item(strschema & "smtpserver")
= "shawmail.cg.shawcable.net" ' "Your SMTP server address here"
.Item(strschema & "smtpserverport") = 25 'specify port number
.Update
End With

With cdoMessage
Set .Configuration = objCDOMail
.to = "macon at g..."
.From = "Winnie The Pooh <macon at s...>"
.CC = ""
.BCC = ""
.Subject = "This is another test from marty"
.TextBody = "This is the text in the body just cdo defaults"
.AddAttachment "C:\temp2\rptSampleCount.rtf"
.AddAttachment "C:\temp2\frontimage.jpeg"
.send
End With

Set cdoMessage = Nothing
Set objCDOMail = Nothing
Exit Sub ' Exit to avoid handler.
ErrorHandler: ' Error-handling routine.
Debug.Print Err.Number & "-" & Err.Description
Set cdoMessage = Nothing
Set objCDOMail = Nothing
Exit Sub
End Sub


Rocky Smolin at Beach Access Software wrote:

>OK.  I'm leaning towards CDO.  At least it looks like just a few minutes to
>gen it up and test it.  
>
>Rocky
>  
>
-- 
Marty Connelly
Victoria, B.C.
Canada




More information about the AccessD mailing list