I did have some fun with email in my original article. I had many responses from individuals who also had some fun. ;> ;> One of those individuals had so much fun that he wrote me to explain how much fun he had. Mr. Perry’s (from Murfreesboro, TN USA) email is below, where he has clearly outlined better use of cdosys.dll.
NOTE: I found some software that makes development a lot faster and improves windows in general:
The following text is quoted from Mr. Perry with my comments in ().
I read your article on CDO/MAPI mail with interest (<grin>). I had just climbed the same slippery slope with a "pro bono" application I'm writing for an emergency service group. I found the answer in cdosys.dll and cdoex.dll. If you have the later cdosys.dll (version 6.1.3940.29) from Win 2000 SP3, it will work without Exchange. It appears to default to MAPI if Exchange is not present. If the user has Office XP, the VB program will use it instead of cdosys.dll. I have experimented with distributing cdosys.dll with my application on Win 98SE machines and it works well on them. Here is my code...
Sure, you can use my code snips. As you say, the availability of info on CDO leaves much to be desired! If you have cdosys.dll (from Win 2000 SP3) or cdoex.dll (from Office XP) on your PC, in the VB IDE, go to "Project/References..." Look for "Microsoft CDO For Exchange 2000 Library" and select it. Click OK and the code will work. You also need to select "Microsoft ActiveX Data Objects 2.5 Library" as the fields in my code for the priority info are accessed via ADO.
Public Sub CDOEmailSend()
Dim iMsg As New cdo.Message
Dim iConf As New cdo.Configuration
Dim tmp As String
Dim iBp As cdo.IBodyPart
Dim cFld As ADODB.Fields
Dim iFld As ADODB.Fields
Set iBp = iMsg
Set cFld = iConf.Fields
Set iFld = iBp.Fields
' Priority structure:
' High: X-Priority=1 Normal: X-Priority=3 Low: X-Priority=5
' X-MSMail-priority=High X-MSMail-priority=Normal X-MSMail-priority=Low
With iFld
.Item("urn:schemas:mailheader:X-Priority") = Switch(Dfld.sEEIPri= "Z", "1", _
Dfld.sEEIPri = "M", "3", Dfld.sEEIPri = "R", "3", Dfld.sEEIPri="P", "1", _
Dfld.sEEIPri = "O", "1", Dfld.sEEIPri = "T", "5")
.Item("urn:schemas:mailheader:X-MSMail-priority") = Switch(Dfld.sEEIPri = "Z", "High",_
Dfld.sEEIPri = "M", "Normal", Dfld.sEEIPri = "R", "Normal", Dfld.sEEIPri = "P", _
"High", Dfld.sEEIPri = "O", "High", Dfld.sEEIPri = "T", "Low")
.Update
End With
With cFld
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = Edat.strMailServer
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPAccountName) = Edat.strMailAccountName
tmp = """" & Edat.strMailDisplayName & """" & " <" & Edat.strMailAddress & """"
.Item(cdoSendUserReplyEmailAddress) = tmp
.Item(cdoSendEmailAddress) = tmp
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = Edat.strMailUserName
.Item(cdoSendPassword) = Edat.strPassword
.Item(cdoURLProxyServer) = "server:80"
.Item(cdoURLProxyBypass) = "<local"
.Item(cdoURLGetLatestVersion) = True
.Update
End With
With iMsg
Set iMsg.Configuration = iConf
.AutoGenerateTextBody = False
.To = eM.To
.CC = eM.CC
.BCC = eM.BCC
.From = tmp
.Subject = eM.Subject
.TextBody = eM.msg
On Error GoTo MailError
Screen.MousePointer = 11
.Send
Screen.MousePointer = 0
End With
Exit Sub
MailError:
Screen.MousePointer = 0
MsgBox Err.Number & ": " & Err.Description, vbExclamation, "Mail Send Failure"
End Sub
End code
I hope you can get some good info from this code snip,
good luck, and thanks to Mr. Perry,
-Matt Burnett