From: Greg Brondo Date: 2003-12-24T07:11:51+09:00 Subject: Re: win32ole, outlook, ruby 1.8 I figured it out. It needed an outlook folder object for the move to work. Here's the code: require 'win32ole' require 'yaml' reList = YAML::load(File.open('rSpamAndSpam.re')) def checkSpam(msgBody, reList) isSpam = false reList.each do |re| if msgBody =~ re isSpam = true break end end return isSpam end outlookInbox = 6 outlookDeletedItems = 3 objOutlook = WIN32OLE.new('Outlook.Application') objNameSpace = objOutlook.GetNamespace("MAPI") objFolder = objNameSpace.GetDefaultFolder(outlookInbox) delFolder = objNameSpace.GetDefaultFolder(outlookDeletedItems) objFolder.Items.each do |i| puts "-" * 60 puts i.Subject isSpam = checkSpam(i.Body, reList) puts "Spam = #{isSpam}" if isSpam puts i.Body i.Move(delFolder) exit end end Thanks! "James Toomey" wrote in message news:8fd3ee12.0312221722.4e5c77ba@posting.google.com... > This code successfully deleted the email with the subject line "Delete > Me" when I tried it: > > require 'win32ole' > olApp = WIN32OLE.new('Outlook.Application') > #The number 6 is the constant olFolderInbox. > inbox = olApp.GetNamespace('MAPI').GetDefaultFolder(6) > emailItems = inbox.Items > emailItems.each {|x| > if x.Subject == 'Delete Me' then > x.Delete > end > } > > What does your original code look like?