A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

If email not sent to specific user



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6  
Old December 20th 07, 01:23 PM posted to microsoft.public.outlook.program_vba
JP[_3_]
external usenet poster
 
Posts: 201
Default If email not sent to specific user

Remove the first "For Each sRecip In Msg.Recipients", it looks like it
was duplicated. Also change "Exit For" to "Exit Sub", or add an error
handler to go straight to the end of the code where the object
variables are released.


HTH,
--JP


On Dec 19, 3:37 pm, Thomas [PBD]
wrote:
Therefore, the ThisOutlookSession Module should read:

Private WithEvents Items As Outlook.Items
-----------------------------------------------------------------
Private Sub Application_Startup()
Dim objNS As Outlook.NameSpace
Set objNS = Application.GetNamespace("MAPI")
Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub
------------------------------------------------------------------
Private Sub Items_ItemAdd(ByVal Item As Object)

If TypeOf Item Is Outlook.MailItem Then
Dim Msg As Outlook.MailItem
Dim NewFwd As Outlook.MailItem
Dim sRecip As Outlook.Recipient
Set Msg = Item

If Msg.SenderName = "specific person" Then
If Msg.Subject = "specific subject" Then
For Each sRecip In Msg.Recipients
counter = 0
For each sRecip in Msg.Recipients
If sRecip.Name = "other specific person" Then
Exit For ' they were sent the email, we can safely exit
Else
counter = counter + 1
end if
Next sRecip

If counter = Msg.Recipients.Count Then ' we cycled through each
recipient and did not find this one
Set NewFwd = Msg.Forward
NewFwd.Recipients.Add("other specific person").Type = olTo
NewFwd.Display ' or .Send
End if
Next sRecip
End If
End If

End If

Set NewFwd = Nothing
Set Msg = Nothing

End Sub

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine the user mailbox for a specific folder dch3 Outlook and VBA 3 December 3rd 07 10:14 PM
Can't open attachments from specific user Sean Outlook Express 4 September 12th 07 07:21 AM
Cannot add specific user to meeting request steve Outlook - Calandaring 0 November 20th 06 03:32 PM
Non user-specific Install... Steven Sinclair Outlook - Installation 3 August 9th 06 03:59 PM
I want to send a new message to a user when a specific email arriv Michael Bauer Outlook and VBA 1 January 9th 06 03:02 PM


All times are GMT +1. The time now is 03:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.