Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Run-time Error '13' Type mismatch (http://www.outlookbanter.com/outlook-vba/57769-run-time-error-13-type.html)

RS September 27th 07 06:16 PM

Run-time Error '13' Type mismatch
 
Hello,

I'm trying to get all the subject lines from a specific folder. Sometimes I
get the error 13 saying type mismatch for the following line:
Set oCurrentEmail = oFolderEMail.Items.Item(i)

I think its because either it came across a read receipt or an email item
that it could not recognize. How can I skip that item and move on to the
next one. Also, sometimes it does go thru with read recipts but it wont pick
up the subject line.

Any help would be greatly appreciated.

Thanks.


Ken Slovak - [MVP - Outlook] September 27th 07 06:21 PM

Run-time Error '13' Type mismatch
 
Either handle the error if it occurs and then move on, or test for the Class
or MessageClass of the item before assigning it to a MailItem type object.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"RS" wrote in message
...
Hello,

I'm trying to get all the subject lines from a specific folder. Sometimes
I
get the error 13 saying type mismatch for the following line:
Set oCurrentEmail = oFolderEMail.Items.Item(i)

I think its because either it came across a read receipt or an email item
that it could not recognize. How can I skip that item and move on to the
next one. Also, sometimes it does go thru with read recipts but it wont
pick
up the subject line.

Any help would be greatly appreciated.

Thanks.



RS September 27th 07 06:46 PM

Run-time Error '13' Type mismatch
 
I tried to handle the message by saying
ErrorHandler:
If Err.Number 0 Then
i = i + 1
Resume Next
End If

It goes to the next message but it duplicated the subject line from previous
message eventhough I'm using oCurrentEmail.Subject to get the subject line.

What type of message class would be an email item. I did go thru help and I
think it would be olMail but then read receipt would probably come under the
same class.

Thanks.
"Ken Slovak - [MVP - Outlook]" wrote:

Either handle the error if it occurs and then move on, or test for the Class
or MessageClass of the item before assigning it to a MailItem type object.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"RS" wrote in message
...
Hello,

I'm trying to get all the subject lines from a specific folder. Sometimes
I
get the error 13 saying type mismatch for the following line:
Set oCurrentEmail = oFolderEMail.Items.Item(i)

I think its because either it came across a read receipt or an email item
that it could not recognize. How can I skip that item and move on to the
next one. Also, sometimes it does go thru with read recipts but it wont
pick
up the subject line.

Any help would be greatly appreciated.

Thanks.




Ken Slovak - [MVP - Outlook] September 27th 07 07:08 PM

Run-time Error '13' Type mismatch
 
If you are looping always clear your variables in each pass so they don't
have data from a previous item if there's a failure of some kind. That's a
general rule, not specific to this case only.

Class == olMail is what you want.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"RS" wrote in message
...
I tried to handle the message by saying
ErrorHandler:
If Err.Number 0 Then
i = i + 1
Resume Next
End If

It goes to the next message but it duplicated the subject line from
previous
message eventhough I'm using oCurrentEmail.Subject to get the subject
line.

What type of message class would be an email item. I did go thru help and
I
think it would be olMail but then read receipt would probably come under
the
same class.

Thanks.



RS September 27th 07 08:23 PM

Run-time Error '13' Type mismatch
 
I tried it and it didnt work....any other suggestions.

"Ken Slovak - [MVP - Outlook]" wrote:

If you are looping always clear your variables in each pass so they don't
have data from a previous item if there's a failure of some kind. That's a
general rule, not specific to this case only.

Class == olMail is what you want.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"RS" wrote in message
...
I tried to handle the message by saying
ErrorHandler:
If Err.Number 0 Then
i = i + 1
Resume Next
End If

It goes to the next message but it duplicated the subject line from
previous
message eventhough I'm using oCurrentEmail.Subject to get the subject
line.

What type of message class would be an email item. I did go thru help and
I
think it would be olMail but then read receipt would probably come under
the
same class.

Thanks.




Dmitry Streblechenko September 28th 07 01:41 AM

Run-time Error '13' Type mismatch
 
What did not work? What is your code?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"RS" wrote in message
...
I tried it and it didnt work....any other suggestions.

"Ken Slovak - [MVP - Outlook]" wrote:

If you are looping always clear your variables in each pass so they don't
have data from a previous item if there's a failure of some kind. That's
a
general rule, not specific to this case only.

Class == olMail is what you want.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"RS" wrote in message
...
I tried to handle the message by saying
ErrorHandler:
If Err.Number 0 Then
i = i + 1
Resume Next
End If

It goes to the next message but it duplicated the subject line from
previous
message eventhough I'm using oCurrentEmail.Subject to get the subject
line.

What type of message class would be an email item. I did go thru help
and
I
think it would be olMail but then read receipt would probably come
under
the
same class.

Thanks.






RS September 28th 07 03:48 PM

Run-time Error '13' Type mismatch
 
I'm running the program to pick up Subject lines from the email. So, I have
to loop through the mailbox based on a date criteria. But sometimes, for
unknown reason, I get Runtime Error 13 type mismatch while its looping
through emails. I cant figure out why would I get the error on certain
emails and not others. It is completely random. I have tried to take the
specific email out of the mailbox based on which email it was on while the
error occured and then run it again it still gives the same error...so I'm
just not sure what's causing the error. I get the error on the following
line of code:
For i = 1 To iCount
Set oCurrentEmail = oFolderEMail.Items.Item(i) --error 13


"Dmitry Streblechenko" wrote:

What did not work? What is your code?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"RS" wrote in message
...
I tried it and it didnt work....any other suggestions.

"Ken Slovak - [MVP - Outlook]" wrote:

If you are looping always clear your variables in each pass so they don't
have data from a previous item if there's a failure of some kind. That's
a
general rule, not specific to this case only.

Class == olMail is what you want.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"RS" wrote in message
...
I tried to handle the message by saying
ErrorHandler:
If Err.Number 0 Then
i = i + 1
Resume Next
End If

It goes to the next message but it duplicated the subject line from
previous
message eventhough I'm using oCurrentEmail.Subject to get the subject
line.

What type of message class would be an email item. I did go thru help
and
I
think it would be olMail but then read receipt would probably come
under
the
same class.

Thanks.






Dmitry Streblechenko September 28th 07 05:47 PM

Run-time Error '13' Type mismatch
 
As Ken has already mentioned, you need to test the Class property using late
binding (note the generic Object below) before you cast a variable to
Outlook.MailItem:

Dim Items As Outlook.Items
Dim DummyItem As Object
Dim CurrentEmail As Outlook.MailItem

set Items = oFolderEMail.Items
iCount = Items.Count
For i = 1 To iCount
set DummyItem = Items.Item(i)
if DummyItem.Class = 43 Then
Set oCurrentEmail = DummyItem


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"RS" wrote in message
...
I'm running the program to pick up Subject lines from the email. So, I
have
to loop through the mailbox based on a date criteria. But sometimes, for
unknown reason, I get Runtime Error 13 type mismatch while its looping
through emails. I cant figure out why would I get the error on certain
emails and not others. It is completely random. I have tried to take the
specific email out of the mailbox based on which email it was on while the
error occured and then run it again it still gives the same error...so I'm
just not sure what's causing the error. I get the error on the following
line of code:
For i = 1 To iCount
Set oCurrentEmail = oFolderEMail.Items.Item(i) --error 13


"Dmitry Streblechenko" wrote:

What did not work? What is your code?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"RS" wrote in message
...
I tried it and it didnt work....any other suggestions.

"Ken Slovak - [MVP - Outlook]" wrote:

If you are looping always clear your variables in each pass so they
don't
have data from a previous item if there's a failure of some kind.
That's
a
general rule, not specific to this case only.

Class == olMail is what you want.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"RS" wrote in message
...
I tried to handle the message by saying
ErrorHandler:
If Err.Number 0 Then
i = i + 1
Resume Next
End If

It goes to the next message but it duplicated the subject line from
previous
message eventhough I'm using oCurrentEmail.Subject to get the
subject
line.

What type of message class would be an email item. I did go thru
help
and
I
think it would be olMail but then read receipt would probably come
under
the
same class.

Thanks.








Ken Slovak - [MVP - Outlook] September 28th 07 06:22 PM

Run-time Error '13' Type mismatch
 
Or even using:

If Items.Item(i).Class = 43 Then
Set oCurrentEmail = Items.Item(i)
' etc.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Dmitry Streblechenko" wrote in message
...
As Ken has already mentioned, you need to test the Class property using
late binding (note the generic Object below) before you cast a variable to
Outlook.MailItem:

Dim Items As Outlook.Items
Dim DummyItem As Object
Dim CurrentEmail As Outlook.MailItem

set Items = oFolderEMail.Items
iCount = Items.Count
For i = 1 To iCount
set DummyItem = Items.Item(i)
if DummyItem.Class = 43 Then
Set oCurrentEmail = DummyItem


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool



RS September 28th 07 06:24 PM

Run-time Error '13' Type mismatch
 
Thanks...That worked. Initially, I was setting my dummyitem as mail item
which was why I continued to get the error message. After setting it up as
an object it worked fine.

"Dmitry Streblechenko" wrote:

As Ken has already mentioned, you need to test the Class property using late
binding (note the generic Object below) before you cast a variable to
Outlook.MailItem:

Dim Items As Outlook.Items
Dim DummyItem As Object
Dim CurrentEmail As Outlook.MailItem

set Items = oFolderEMail.Items
iCount = Items.Count
For i = 1 To iCount
set DummyItem = Items.Item(i)
if DummyItem.Class = 43 Then
Set oCurrentEmail = DummyItem


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"RS" wrote in message
...
I'm running the program to pick up Subject lines from the email. So, I
have
to loop through the mailbox based on a date criteria. But sometimes, for
unknown reason, I get Runtime Error 13 type mismatch while its looping
through emails. I cant figure out why would I get the error on certain
emails and not others. It is completely random. I have tried to take the
specific email out of the mailbox based on which email it was on while the
error occured and then run it again it still gives the same error...so I'm
just not sure what's causing the error. I get the error on the following
line of code:
For i = 1 To iCount
Set oCurrentEmail = oFolderEMail.Items.Item(i) --error 13


"Dmitry Streblechenko" wrote:

What did not work? What is your code?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"RS" wrote in message
...
I tried it and it didnt work....any other suggestions.

"Ken Slovak - [MVP - Outlook]" wrote:

If you are looping always clear your variables in each pass so they
don't
have data from a previous item if there's a failure of some kind.
That's
a
general rule, not specific to this case only.

Class == olMail is what you want.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"RS" wrote in message
...
I tried to handle the message by saying
ErrorHandler:
If Err.Number 0 Then
i = i + 1
Resume Next
End If

It goes to the next message but it duplicated the subject line from
previous
message eventhough I'm using oCurrentEmail.Subject to get the
subject
line.

What type of message class would be an email item. I did go thru
help
and
I
think it would be olMail but then read receipt would probably come
under
the
same class.

Thanks.










All times are GMT +1. The time now is 11:10 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com