outlook vba If statement

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?
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
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,225,609
Messages
6,185,985
Members
453,333
Latest member
BioCoder84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top