473,834 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Move emails (.msg files) between an Outlook inbox and a file direc

What I am after would be a VB script perhaps using CDO to access the inbox of
a mailbox, and push or pull messages in or out to a flat file directory on
disk
--
Tom North
May 6 '06 #1
1 2173
Imports System
Imports System.Reflecti on
Imports Outlook = Microsoft.Offic e.Interop.Outlo ok

Namespace PACKERSROCK
Public Class VIKINGSSUCK

Public Shared Function Main() As Integer
Try

Dim oApp As Microsoft.Offic e.Interop.Outlo ok.Application =
New Outlook.Applica tion()

Dim oNS As Outlook.NameSpa ce = oApp.GetNamespa ce("mapi")

oNS.Logon(Missi ng.Value, Missing.Value, False, True)
Dim oInbox As Outlook.MAPIFol der =
oNS.GetDefaultF older(Outlook.O lDefaultFolders .olFolderInbox)
Dim oItems As Outlook.Items = oInbox.Items

Dim oMsg As Outlook.MailIte m = CType(oItems.Ge tFirst(),
Outlook.MailIte m)

'Check for attachments.
Dim AttachCnt As Integer = oMsg.Attachment s.Count
Debug.WriteLine ("Attachment s: " + AttachCnt.ToStr ing())

If AttachCnt > 0 Then
Dim i As Integer
For i = 1 To AttachCnt Step i + 1
Debug.WriteLine (i.ToString() + "-" +
oMsg.Attachment s(i).DisplayNam e)
Next
End If

oMsg.SaveAs("C: \TESTMSG.DOC", Nothing)
oNS.Logoff()
oMsg = Nothing
oItems = Nothing
oInbox = Nothing
oNS = Nothing
oApp = Nothing
'End Try

'Error handler.
Catch e As Exception
Debug.WriteLine ("{0} Exception caught: ", e.ToString)

' Return value.
Return 0
End Try
End Function
End Class
End Namespace

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"tom north" <to******@discu ssions.microsof t.com> wrote in message
news:BB******** *************** ***********@mic rosoft.com...
What I am after would be a VB script perhaps using CDO to access the inbox
of
a mailbox, and push or pull messages in or out to a flat file directory on
disk
--
Tom North

May 6 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

40
11927
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 following import win32com.client
1
1357
by: Li Weng | last post by:
Hi, I use WebDAV to move emails from one folder to another folder. The moving is ok. But some of emails still show up in the original folder. I use Outlook web Access to check, they are gone. But Outlook still has them. I run WebDAV program again and couldn't find them. Is there cache in Outlook that I need to clean it? Thanks in advance. Li
0
1181
by: Bob Bykerk | last post by:
Hi guys, I am integrating the outlook inbox into a personnel database and have successfully linked the table. I can see where an e-mail has attachments, but can't get to them. Has anyone done this using VBA ? Cheers, Bob
0
1239
by: Bob Dydd | last post by:
Hi Everybody I am looking for a way to connect and disconnect to the Ms Outlook Inbox programmatically from a command button on a form . At the moment it is easy enough to do by going to the database container and doing the following: 1. select file 2. select Get external data
0
990
by: Mike P | last post by:
I am trying to access my local outlook inbox via the outlook object model, but keep getting this error : Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 8007000 Can anybody help me out?
0
1130
by: im tryin | last post by:
Hi Im am using vb.net and want to read my outlook inbox from my windows application. i also want it to refresh every 1minute or so for new emails does anyone have any idea how i would integrate outlook in vb.net windows application? Please help
1
1458
by: Mike P | last post by:
I am trying to use a foreach loop to get everything in an Outlook inbox, but in Outlook 11, there is no Item property. How do I get at each item using a foreach loop? *** Sent via Developersdex http://www.developersdex.com ***
0
1543
by: grant | last post by:
Has anyone got a sample db that has a form to list an Outlook inbox and subfolders? I want to be able to mimic the tree style list of folders in Outlook so the user can browse the contents on the outlook inbox and subfolders under it, and double click on a message to open it in Outlook. I've looked at Dev's site where he has the MAPIStuff.mdb but its only coe the raw code and no examples of how to use it.
7
2454
by: BlackMustard | last post by:
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. Sub UnimportantMail() Dim myTargetFolder As MAPIFolder Dim myCurrentItem As Outlook.MailItem Set myCurrentItem = Application.ActiveExplorer.Selection Set...
4
5011
by: venutaurus539 | last post by:
Hi all, How can I access the body of a mail in Outlook Inbox? I tried various options like message.Body or message.Mesg etc. but didn't work. I could get the subject of the mail using message.Subject though. Any help is appreciated. Thanks in advance, Venu
0
9643
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10544
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9326
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7754
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5624
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5790
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3079
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.