473,597 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need a macro for office outlook 2003

89 New Member
Hello

I have the following macro for outlook:

Expand|Select|Wrap|Line Numbers
  1. Dim oApp As Application
  2. Dim oNS As NameSpace
  3. Dim oMsg As Object
  4. Dim bDoAction As Boolean
  5. Dim oAttachments As Outlook.Attachments
  6. Dim iSubject, dirPath, tu, hu, tot, Rcp As String
  7. Dim i, iAttachCnt As Integer
  8.  
  9.  
  10. 'Counting files
  11. Private Function CountFiles(ByVal folderPath As String, Optional ByVal fileType As String = "*")
  12.  
  13.     Set oFSO = CreateObject("Scripting.FileSystemObject")
  14.     Dim count As Long
  15.     Set oFolder = oFSO.GetFolder(folderPath)
  16.     Set oFiles = oFolder.Files
  17.  
  18.     fileType = LCase(Trim(fileType))
  19.  
  20.     If fileType = "*" Then
  21.         CountFiles = oFiles.count
  22.     Else
  23.         For Each oFile In oFiles
  24.             If LCase(oFSO.GetExtensionName(oFile.Name)) = fileType Then count = count + 1
  25.         Next oFile
  26.         CountFiles = count
  27.    End If
  28.  
  29. End Function
  30. Sub JobScanning()
  31.  
  32.  
  33.     '*************
  34.     ' Finding files in PTA emails and saves them respective folder
  35.     ' Objective:
  36.     ' Save email and attachments in respektive folders
  37.     '*************
  38.  
  39.     Set oApp = New Outlook.Application
  40.     Set oNS = oApp.GetNamespace("MAPI")
  41.  
  42.     Set oFolder = oNS.Folders("Public Folders").Folders("All Public Folders").Folders("PTA").Folders("JobScanning")
  43.  
  44.     For Each oMsg In oFolder.Items
  45.         bDoAction = True
  46.         With oMsg
  47.         'tot = the first 5 characters in subject
  48.         tot = Left(.Subject, 5)
  49.             If Val(tot) > 7999 Then
  50.                 'isubject = whole subject
  51.         iSubject = .Subject
  52.         'tu = first 2 characters in subject
  53.                 tu = Left(.Subject, 2)
  54.         'hu = first 3 characters in subject
  55.                 hu = Left(.Subject, 3)
  56.  
  57.         'building folder path
  58.                 dirPath = "j:\job\" & tu & "000-" & tu & "999\" & hu & "00-" & hu & "99\" & tot & "\"
  59.                 If CountFiles(dirPath) > 1 Then
  60.                         'warning
  61.             If MsgBox("there is" & CountFiles(dirPath) & " files in folder" & tot & "\, ", 49, "PTA emails - warning") = vbCancel Then bDoAction = False
  62.                 End If
  63.  
  64.  
  65.  
  66.  
  67.                     '***********
  68.                     ' saving attachments in folders
  69.                     '***********
  70.                     iAttachCnt = .Attachments.count
  71.                     If iAttachCnt > 0 Then
  72.                         For iCtr = 1 To iAttachCnt
  73.                             With .Attachments.Item(iCtr)
  74.                                     .SaveAsFile dirPath & .FileName
  75.                             End With
  76.                         Next iCtr
  77.                     End If
  78.                     'deleting email
  79.             .delete
  80.            End If
  81.  
  82.         End With
  83.     Next
  84. End Sub
  85.  
  86.  
  87.  
  88.  
Now i need to do exactly the same again in a new macro but instead of looking at the subject name characters i need to be looking at attach file name characters. Can anyone help with this problem...????

Thanks in advance
Jul 28 '09 #1
0 1604

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

Similar topics

2
1810
by: Lauren Wilson | last post by:
Hi Folks, I have a widely distributed Access 200 Application. I must retain my ability to support users who are still on Access 2000 and Access 2000 Runtime. However I also need to upgrade my development environment to Office 2003 Professional. My question is: Where can I find a comprehensive description of the known issues that will affect my ability to do all of the above after I upgrade my own development environment to Office...
2
1091
by: Thilaka | last post by:
Some time back i learnt that Office 2003 will be built to be able to use managed code (instead of the classic VBA). Is this true. Can someone please, give me a link where i could learn about this (a few samples perhaps). (preferably Word or Excel 2003). Regards, Thilaka
2
2603
by: Miguel Arenas | last post by:
I want to develop a aplication with VB.2003 and Microsoft outlook 2003. I have this code. Imports OutLook = Microsoft.Office.Interop.Outlook Imports System.Reflection Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
1
3213
by: =?Utf-8?B?cm9i?= | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox and server (Exchange server mail box) to connect and then save the mailitems(from Inbox or any other folder) based on a filter to a*.msg file. I want to achieve this using only one Interop dll if this is possible. Tried so far:
1
2857
by: allbelonging | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox and server (Exchange server mail box) to connect and then save the mailitems(from Inbox or any other folder) based on a filter to a*.msg file. I want to achieve this using only one Interop dll if this is possible. Tried so far:
2
2036
by: =?Utf-8?B?SmVmZiBD?= | last post by:
I am already at the 3rd tier of MS and they cannot figure this out yet.. Bought Office 2007 Small Business Upgrade. Install completed the first time (only), yet each time you start Outlook, Word or Excel, the windows installer starts again. You can successfully cancel out of all the pop-ups and eventually get to the program, but something is not right. Plus - Business contact manager does not work nor does Accounting Express. Here is what...
1
7237
by: mike11d11 | last post by:
I am using this code to create an email to send automaticaly in my program, the only problem is I get the security warning and I just want the email to go out on its own without the warning. I heard this can only be done by creating your own Com add-in but I really dont know how to do that and am pretty new to the programming world. Any help with my code below would be greatly appreciated, oh yeh I'm using outlook 2003 pro. Dim oOutL...
11
20199
by: Don | last post by:
QUESTIONS: 1. Has anyone figured out how to successfully install the Office 97 Pro Service Release 2 patch in Vista? 2. Has anyone successfully installed an Office 97 Pro CD (SR2 version) in Vista? DETAILS: My setup: Dell Inspiron notebook with Vista Business edition My CD: Office 97 Professional (Service Release 1) Upgrade
4
1533
by: John | last post by:
Hi I have an access app that uses word and outlook and both are referenced in the access app. The problem is that my client have outlook 2000 and word 2000 while my development machine has outlook 2003 and word 2003. How can I package the app for distribution so that it installs fine at clients end? Thanks Regards
0
7967
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6687
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
5847
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
5428
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
3923
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2403
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1493
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1233
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.