473,396 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

moving emails in outlook - type mismatch error

hi all,

i have used the following macro to move unimportant (i.e. non-work related) mail in my outlook inbox into a folder in personal folders. it has worked for a long time, but suddenly it gives a "type mismatch" error when trying to move the mailitem.

Expand|Select|Wrap|Line Numbers
  1. Sub UnimportantMail()
  2.     Dim myTargetFolder As MAPIFolder
  3.     Dim myCurrentItem As Outlook.MailItem
  4.  
  5.     Set myCurrentItem = Application.ActiveExplorer.Selection
  6.     Set myTargetFolder = Outlook.GetNamespace("MAPI").Folders("Personal Folders").Folders("Unimportant stuff")
  7.  
  8.     myCurrentItem.UnRead = False
  9.  
  10.     myCurrentItem.Move (myTargetFolder)
  11.  
  12.     Set myCurrentItem = Nothing
  13.     Set myTargetFolder = Nothing
  14. End Sub
i have the same problem in all other macros trying to move anything (both folders and mailitems) around in outlook. why has this error suddenly started to occur while the macro worked just fine with the exact same code before, and what can i do about it?

thank you in advance for your help!
Nov 26 '07 #1
7 2434
[tilt tilt...]

i really need help with this - i use these macros all the time, and when nothing's working everything takes twice as much time as it does if they work... so please - help! ;)
Nov 26 '07 #2
Killer42
8,435 Expert 8TB
At a guess, you've just upgraded Outlook or something.

Which line throws the error?
Nov 28 '07 #3
At a guess, you've just upgraded Outlook or something.

Which line throws the error?
line 10:
Expand|Select|Wrap|Line Numbers
  1. myCurrentItem.Move (myTargetFolder)
Dec 6 '07 #4
and by the way (excuse the double posting, i didn't find the edit button) i don't think outlook has updated recently. maybe it has, but in that case it was just a very minor update, since i didn't notice. corporate networks...
Dec 7 '07 #5
Killer42
8,435 Expert 8TB
Sorry for the delay, I've been away. It's a shame nobody else has jumped into the thread, as I don't know anything about Outlook.

The only thing I can suggest is to try removing the brackets around myTargetFolder, just to see whether it makes any difference.
Dec 9 '07 #6
Sorry for the delay, I've been away. It's a shame nobody else has jumped into the thread, as I don't know anything about Outlook.

The only thing I can suggest is to try removing the brackets around myTargetFolder, just to see whether it makes any difference.
you must have magic fingers - it works! thanks!

i really do feel happy i started .net - passing parameters to a routine without parenthesis feels just odd... and a compiler getting a "type mismatch" error when you try this way is even worse. do you know if there's any way to write macros in vb.net instead?

anyway, thanks for helping me out!
Dec 11 '07 #7
Killer42
8,435 Expert 8TB
you must have magic fingers - it works! thanks!
Glad to hear it. :) I've always had a bit of a knack for debugging.

i really do feel happy i started .net - passing parameters to a routine without parenthesis feels just odd... and a compiler getting a "type mismatch" error when you try this way is even worse. do you know if there's any way to write macros in vb.net instead?
No idea, sorry.

The parameter syntax all seems pretty straightforward to me, because I've used VB and its predecessors for so long. Putting parentheses around the parameter forces it to be treated as an expression and resolved first, before passing it. In this case, my guess is the result might have been a string from the object's default property or something.

anyway, thanks for helping me out!
That's what we're here for. :)
Dec 12 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

40
by: ian | last post by:
Hi, I'm a newbie (oh no I can here you say.... another one...) How can I get Python to send emails using the default windows email client (eg outlook express)? I thought I could just do the...
4
by: Nicole | last post by:
I found this code below to use to send emails using VB with Outlook. However, it gives these errors. 'Send' is ambiguous across the inherited interfaces 'Outlook._MailItem' and...
5
by: horsetransport | last post by:
Hello, Below is what I "Know how to do" but it doesn't accomplish what I want I have table called sndmail fields that matter useremail and mailsent
16
by: Kosmos | last post by:
Good afternoon everyone, just wondering if anyone knew if it's possible to send meetings or appointments through email when you run VBA or SQL code in Access 2003? The following is the code I've been...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.