D
David
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
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