473,787 Members | 2,881 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 1614

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

Similar topics

2
1820
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
1097
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
2612
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
3224
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
2872
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
2049
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
7245
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
20226
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
1540
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
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
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
8993
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...
0
6749
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
5398
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
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
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
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.