473,382 Members | 1,247 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,382 software developers and data experts.

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 2147
Imports System
Imports System.Reflection
Imports Outlook = Microsoft.Office.Interop.Outlook

Namespace PACKERSROCK
Public Class VIKINGSSUCK

Public Shared Function Main() As Integer
Try

Dim oApp As Microsoft.Office.Interop.Outlook.Application =
New Outlook.Application()

Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")

oNS.Logon(Missing.Value, Missing.Value, False, True)
Dim oInbox As Outlook.MAPIFolder =
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderInbox)
Dim oItems As Outlook.Items = oInbox.Items

Dim oMsg As Outlook.MailItem = CType(oItems.GetFirst(),
Outlook.MailItem)

'Check for attachments.
Dim AttachCnt As Integer = oMsg.Attachments.Count
Debug.WriteLine("Attachments: " + AttachCnt.ToString())

If AttachCnt > 0 Then
Dim i As Integer
For i = 1 To AttachCnt Step i + 1
Debug.WriteLine(i.ToString() + "-" +
oMsg.Attachments(i).DisplayName)
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******@discussions.microsoft.com> wrote in message
news:BB**********************************@microsof t.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
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...
1
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....
0
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...
0
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...
0
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...
0
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...
1
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...
0
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...
7
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...
4
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.