I
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Cleaning up shipping files (2002)
Home » Forums » AskWoody support » Productivity software by function » MS Outlook and email programs » Cleaning up shipping files (2002)
- This topic has 8 replies, 3 voices, and was last updated 22 years, 7 months ago.
Viewing 1 reply threadAuthorReplies-
WSAndrewO
AskWoody LoungerOctober 18, 2002 at 9:02 pm #625146 -
WSarage
AskWoody Lounger -
WSAndrewO
AskWoody Lounger -
WSarage
AskWoody Lounger
-
-
WSAndrewO
AskWoody LoungerOctober 25, 2002 at 8:54 pm #626807Arage
OK – try the following code.
Cut and paste this to the Outlook “ThisOutLookSession” code space.
Note that by default Outlook disables macros and doesn’t tell you it has – you’ll need to enable them to at most ‘Medium’ security.I’ve had to make some assumptions for the purposes of design that you will need to review.
This routine triggers on the NEWMAIL event, and looks for mail with file attachments
If it sees file types CSV TXT or 001 it then asks if it should convert them.
You can change the file types looked for by modifying the variable ‘MyExts’ – you can add more by just typing .EXT inside the quotes where EXT is your new extension.
For testing I also used directory C:TEMP to create reformatted files in – change MyPath as needed for your network drive.
I have coded changes to data as follows –
Column 2 has 001 added
Columns 4 & 5 have quotes
Column 4 has R00 at front
Column 5 has S045 at front
The LAST column has date extended. Note that I specifically coded it as the last, rather than 10th column because this protects the code if you text fields ever contain commas
The program is designed so that similar changes could be made without a big deal
Public Myolapp As Variant
Public I As Long
Public J As Long
Public MyExt As String
Public MyExts As String
Public MyFile As String
Public MyPath As StringPrivate Sub Application_NewMail()
‘ Identifies incoming mail that has an attachment that matches our target type
‘ if so, asks, and translates it to new format and save‘ Change the following two constants as required to get things working right
‘ First is simply a list of valid extensions to trigger reformating actionMyExts = “.CSV.TXT.001”
‘ Second is the path for re-formatted files to go to
MyPath = “C:TEMP”
‘ Preliminary setup to view new mail
Set Myolapp = CreateObject(“Outlook.Application”)
Set myNameSpace = Myolapp.GetNamespace(“MAPI”)
Set Myolapp.ActiveExplorer.CurrentFolder = _
myNameSpace.GetDefaultFolder(olFolderInbox)‘ Identify unread mail and deal with it
With Myolapp.ActiveExplorer.CurrentFolder
For I = 1 To .Items.Count
If .Items(I).UnRead = True Then
For J = 1 To .Items(I).Attachments.Count
MyFile = .Items(I).Attachments(J).DisplayName
MyExt = Right(MyFile, 4)
If InStr(1, MyExts, MyExt, vbTextCompare) > 0 Then
If MsgBox(“Reformat file ‘” & MyFile & “‘?”, buttons:=vbOKCancel) = 1 Then
MyFile = MyPath & “” & Left(MyFile, Len(MyFile) – 4) & “._B4”
.Items(I).Attachments(J).SaveAsFile MyFile
Reformat MyFile
End If
.Items(I).UnRead = False
End If
Next J
End If
Next I
End WithEnd Sub
Sub Reformat(target As String)
Dim I As Long
Dim J As Long
Dim DateCol As Long
Dim MyRec As String
Dim MyFields(100) As String‘ This would have been easier in Excel but it cannot refrain from re-formating quotes
‘ so – lets just do it the hard way
‘ Just read the file line by line, break it out into fields, and then rewriteOpen target For Input As #1
Open Left(target, Len(target) – 4) & “.CSV” For Output As #2
Line Input #1, MyRec
While Not EOF(1)
‘ it is easier and less bug-prone to split into fields than try to be clever
J = 1
I = InStr(1, MyRec, “,”)
While I > 0
MyFields(J) = Left(MyRec, I – 1)
MyRec = Mid(MyRec, I + 1)
J = J + 1
I = InStr(1, MyRec, “,”)
Wend
MyFields(J) = MyRec‘ This is the section that makes the requested changes
MyFields(2) = Left(MyFields(2), Len(MyFields(2)) – 1) & “001”””
MyFields(4) = “””R00” & MyFields(4) & “”””
MyFields(5) = “””S045” & MyFields(5) & “”””
‘ Set the column for date as the last column.
‘ Why? to protect from possible commas in the text fields
MyFields(J) = Left(MyFields(J), Len(MyFields(J)) – 3) & “20” & Right(MyFields(J), 3)‘ then we put it all back together and write it out
For I = 1 To J – 1
Print #2, MyFields(I); “,”;
Next I
Print #2, MyFields(J)
Line Input #1, MyRec
Wend
Close #1
Close #2End Sub
-
-
-
WSRknott
AskWoody Lounger -
WSarage
AskWoody Lounger -
WSAndrewO
AskWoody LoungerOctober 25, 2002 at 9:54 pm #626808Oops
Reading between the lines of this message I detect that the changes requested are not as ‘mindless’ as I coded.
I begin to think that things like “S045” only have to be added if they are not already there.
My suggestion is that we send direct emails for the fine-tuning – rather than bother the board.
-
-
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Google’s Veo3 video generator. Before you ask: yes, everything is AI here
by
Alex5723
5 hours, 51 minutes ago -
Flash Drive Eject Error for Still In Use
by
J9438
7 hours, 24 minutes ago -
Windows 11 Insider Preview build 27863 released to Canary
by
joep517
1 day ago -
Windows 11 Insider Preview build 26120.4161 (24H2) released to BETA
by
joep517
1 day ago -
AI model turns to blackmail when engineers try to take it offline
by
Cybertooth
4 hours, 23 minutes ago -
Migrate off MS365 to Apple Products
by
dmt_3904
5 hours, 11 minutes ago -
Login screen icon
by
CWBillow
21 minutes ago -
AI coming to everything
by
Susan Bradley
3 hours, 10 minutes ago -
Mozilla : Pocket shuts down July 8, 2025, Fakespot shuts down on July 1, 2025
by
Alex5723
1 day, 16 hours ago -
No Screen TurnOff???
by
CWBillow
1 day, 16 hours ago -
Identify a dynamic range to then be used in another formula
by
BigDaddy07
1 day, 17 hours ago -
InfoStealer Malware Data Breach Exposed 184 Million Logins and Passwords
by
Alex5723
2 days, 4 hours ago -
How well does your browser block trackers?
by
n0ads
1 day, 15 hours ago -
You can’t handle me
by
Susan Bradley
15 hours, 10 minutes ago -
Chrome Can Now Change Your Weak Passwords for You
by
Alex5723
1 day, 7 hours ago -
Microsoft: Over 394,000 Windows PCs infected by Lumma malware, affects Chrome..
by
Alex5723
2 days, 16 hours ago -
Signal vs Microsoft’s Recall ; By Default, Signal Doesn’t Recall
by
Alex5723
1 day, 19 hours ago -
Internet Archive : This is where all of The Internet is stored
by
Alex5723
2 days, 16 hours ago -
iPhone 7 Plus and the iPhone 8 on Vantage list
by
Alex5723
2 days, 16 hours ago -
Lumma malware takedown
by
EyesOnWindows
2 days, 5 hours ago -
“kill switches” found in Chinese made power inverters
by
Alex5723
3 days, 1 hour ago -
Windows 11 – InControl vs pausing Windows updates
by
Kathy Stevens
3 days, 1 hour ago -
Meet Gemini in Chrome
by
Alex5723
3 days, 5 hours ago -
DuckDuckGo’s Duck.ai added GPT-4o mini
by
Alex5723
3 days, 5 hours ago -
Trump signs Take It Down Act
by
Alex5723
3 days, 13 hours ago -
Do you have a maintenance window?
by
Susan Bradley
1 day, 18 hours ago -
Freshly discovered bug in OpenPGP.js undermines whole point of encrypted comms
by
Nibbled To Death By Ducks
2 days, 15 hours ago -
Cox Communications and Charter Communications to merge
by
not so anon
3 days, 17 hours ago -
Help with WD usb driver on Windows 11
by
Tex265
32 minutes ago -
hibernate activation
by
e_belmont
4 days, 1 hour ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.