Need to resolve names using CDOEX to send e-mails in a VB6 program
Posted on 2004-03-25
I'm amending a VB6 program I inherited that used to use CDO 1.21 to either print letters or to send attachments via e-mail. Since we've moved to Windows 2000 I need to upgrade this to CODEX. (It's form, not Web based).
The program works OK if I give it a full e-mail address (email@example.com, for example). However, the old program included code to resolve the address if it was entered as a name in the users (Outlook 2000) address book. So if the user had an address book entry for john hyde pointing to firstname.lastname@example.org, the user could enter an address of "john hyde", Jo Hyd" or anything else that Outlook would normally resolve. This was accomplished with a .Recipients.Resolve" as follows:
Dim objMessage As MAPI.Message
Set objRecipient = objMessage.Recipients.Add(txtEmail.Text)
' If the txtCopiesTo text box is not empty then add this recipient too
If txtCopiesTo.Text <> "" Then
Set objRecipient = objMessage.Recipients.Add(txtCopiesTo.Text)
objRecipient.Type = olCC
' On error - go to the CDO error handling which traps errors pertaining
' to email recipient resolution
strLabel = "Send11"
On Error GoTo CDO_Error
' Resolve the email addresses
' Reset back to Normal error handling
On Error GoTo Error_Label
' Cycle through the recipients (currently just two) to extract the
' resolved email addresses and place them in the Correspondence form
strLabel = "Send12"
For Each objRecipient In objMessage.Recipients
Select Case objRecipient.Type
Me.txtEmail.Text = objRecipient.AddressEntry
Me.txtCopiesTo.Text = objRecipient.AddressEntry
' Do nothing
' Ask the user if they want to send the email to the resolved recipients.
' If so, the correspondence is then saved to history, and sent via email.
strLabel = "Send13"
If vbYes = MessageConfirm(503, txtEmail.Text, txtCopiesTo.Text) Then
There is no ".Recipients" property available using CDOEX, so the question is - can I emulate this code using CDOEX for users who have Outlook loaded on their machines, or is CDOEX so removed from the Outlook interface that this is no longer possible/practical? (If it is possible, would the same code work for people with Outlook Express?).
As a tack-on question, I'll also need to send Fax messages using the same program. Can anyone point me to some code to do this using CDOEX? (We have Zetafax set up on site - can we simply send a file to the Zetafax printer?)
A speedy answer would be appreciated - hence the 500 point allocation.
With thanks in anticipation,