Kris75
Board Regular
- Joined
- Jul 29, 2009
- Messages
- 143
Hi
I'm Very New to VB, but i am working on a project where an email received is automatically replied to with a certain body of text, 10 days after it is received.
I have acheived this, but now the paymasters want me to exclude certain criteria, namely emails received from within its own company. (anything ending in @redcar-cleveland.gov.uk) there will be other exclusions, but if i can do it once, then i can do it again.
Can anyone help me?
I'm Very New to VB, but i am working on a project where an email received is automatically replied to with a certain body of text, 10 days after it is received.
I have acheived this, but now the paymasters want me to exclude certain criteria, namely emails received from within its own company. (anything ending in @redcar-cleveland.gov.uk) there will be other exclusions, but if i can do it once, then i can do it again.
Can anyone help me?
HTML:
Public WithEvents myOlItems As Outlook.Items
Public Sub Application_Startup()
' Reference the items in the Inbox. Because myOlItems is declared
' "WithEvents" the ItemAdd event will fire below.
Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub myOlItems_ItemAdd(ByVal Item As Object)
' Check to make sure it is an Outlook mail message, otherwise
' subsequent code will probably fail depending on what type
' of item it is.
If TypeName(Item) = "MailItem" Then
' Reply the item just received
Set myreply = Item.Reply
‘ Main Body of email. Adjust message to suit, vbCrLf produces a new line for text
Myreply.Body = "if you have received this message please ignore it" _
& vbCrLf & "i am currently testing a programmable functionality " _
& vbCrLf & "of Outlook to improve customer services" _
& vbCrLf & "thank you”
‘ Sends reply at 9am 10 days after receipt.
myreply.DeferredDeliveryTime = Date + 10 & " 09:00"
' Command for sending email.
myreply.Send
End If
End Sub