Code To Add "CC" Fails In 2002

  • Thread starter consulttech2004
  • Start date
C

consulttech2004

Folks,

The following code works in Outlook 2000 to add someone to the CC field

of a message in Outlook 2000. It fails on the very last line of the
function in Outlook 2002. The names appear in the code as they
resolve. Commenting out the last line solves the issue in Outlook
2002, but then the message stays open after it sends. Anyone know why?


Function ufnSend1CC()

Dim NmSpc As NameSpace
Dim insp1 As Outlook.Inspector
Dim msg1 As Outlook.MailItem
Dim msg2 As Outlook.MailItem
Dim objRecipient As Outlook.Recipient

Set NmSpc = Application.GetNamespace("Mapi")
Set insp1 = Application.ActiveInspector

If insp1.CurrentItem.Class = olMail Then
Set msg1 = insp1.CurrentItem
Else
Exit Function
End If

If msg1.CC = "John Doe" Then

Set objRecipient = msg1.Recipients.Add("Richard Roe")
objRecipient.Type = olCC

Set msg2 = msg1.Copy
msg2.Send

msg1.Close olDiscard
ufnSend1CC = True
Else
ufnSend1CC = False
End If

End Function


Note: It is called like this:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)

Cancel = ufnSend1CC

End Sub

Thanks so much for your help!

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top