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

Need a macro for office outlook 2003

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 1599

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

Similar topics

2
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...
2
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...
2
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...
1
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...
1
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...
2
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...
1
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...
11
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...
4
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.