- Joined
- Jan 23, 2012
- Messages
- 1
- Reaction score
- 0
Hi - i am very new to VB and and not receieved any training.
I wanted to write a code for Outlook to reply to a message 10 days after it had been received. this is how far i have got so far, however this code will also delete a copy of the message. my question is why, and how do i stop it doing this
Thanks .
I wanted to write a code for Outlook to reply to a message 10 days after it had been received. this is how far i have got so far, however this code will also delete a copy of the message. my question is why, and how do i stop it doing this
Thanks .
Code:
[FONT=Times New Roman][SIZE=3]'With Subject Search[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Public WithEvents myOlItems As Outlook.Items [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Public Sub Application_Startup() [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] ' Reference the items in the Inbox. Because myOlItems is declared[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] ' "WithEvents" the ItemAdd event will fire below.[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]End Sub[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Private Sub myOlItems_ItemAdd(ByVal Item As Object)[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Dim SubJect As String[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]SubJect = Item.SubJect[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Dim SenderName As String[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]SenderName = Item.SenderName[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] 'Will not reply to Email that has been replied to or Forwarded[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] If TypeName(Item) = "MailItem" And SenderName Like "*" & "Young" & "*" Or _[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] SenderName Like "*" & "young" & "*" Then ' name not emailthis works[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] Else [/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] [/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Set myreply = Item.Reply [/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] myreply.Body = "if you have received this message please ignore it" _[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] & vbCrLf & "i am currently testing a programmable functionality " _[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] & vbCrLf & "of Outlook to improve customer services" _[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] & vbCrLf & "thank you "[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] ' This will send the Response at 9 am 10 days after the Email has been received.[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]myreply.DeferredDeliveryTime = Date + 10 & " 09:00"[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]myreply.Send ' Send it[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] End If[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]End Sub[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]