I below code to replyall to email shows
"Run-time error 13 type mismatch"
when it runs to Next (for each next loop).
I set up the rule for email received today. When it comes to next (next date), it shows the error message.
I debugged, it stopped the error message until the received-time is today.
sub fwdmail ()
dim i as long
dim otlk as outlook.application
dim nmspc as outlook.namespace
dim olmail as Outlook.MailItem
dim objfolder as Outlook.MAIPfolder
dim oreply as Outlook.MailItem
set otlk=New Outlook.Applicaiton
Set Nmsp=otlk.GetNamespace("MAPI")
Set objfolder=nmspc.getdefaultFolder("olFolderInbox).Folder("notice")
for each olmail in objfolder.Items
if olmail.ReceivedTime>=Format(Date, "YYYY/MM/DD") then
' do the stuff here
end if
next
I tired to check if a mailitem type, but got the same error message.
for each olmail in objfolder.Items
if typeof olmail is outlook.item then
if olmail.ReceivedTime>=Format(Date, "YYYY/MM/DD") then
' do the stuff here
end if
end if
next
TypeOf
the item before trying to loop. – BigBenItems.Restrict
instead of looping. – BigBenMailItem.ReceivedTime
is aDate
, don't compare it to aVariant/String
, which is whatFormat
returns. – BigBen