Archive for May, 2007

Cox Blocks Outgoing Email As Spam

Friday, May 4th, 2007

Let me preface this by saying that I think Cox is the best home internet service I’ve ever dealt with.  It’s fast and reliable and most importantly you always speak to someone for whom english is a first language.  They answer the phone quickly and for the most part I don’t have any problem with them. 

Ok Here’s a great one.  I was with a client.  We do computer service as well as web design and hosting.  He has been complaining, since he started using his new @domainname.com email address instead of his @cox.net address, about messages not being received by people he was sending to.  Since he is using a Cox home connection for internet he has to use smtp.west.cox.net to send anything on port 25.  All email has to go through Cox unless he uses an alternate port email service… 

Ok enough background.  Today he calls me and says his emails are all bouncing back to him.  I ask him to send me the bounced message (via another account).

 

Here is the message he recieved. Highlights are mine.

Your message did not reach some or all of the intended recipients.

 

      Subject:            FW: Here are the IO’s and Posting Instructions for the 2 offers.

      Sent:                 5/3/2007 4:15 PM

 

The following recipient(s) could not be reached:

 

      ‘Yan Herndon’ on 5/3/2007 4:15 PM

            552 unFF1W00S1Vdu980000000 This message was undeliverable.  This message has been found to be a potential spam message, and has therefore been blocked.  Please visit http://coxagainstspam.cox.net for more information.

 

So I go take a look at the page and blah blah we are protecting you, blah blah.  I tell him to call cox and ask them what’s up.  I figure that since he is in the mortgage biz and there is a link to his web site in his signature maybe its just close enough to get caught.

So he calls them up.   Tells the above…  All the first level techs can’t figure anything out etc.  He pushes harder.  (the guys a salesman…)  Finally he get’s second level techs on the phone and they tell him a ring of stories.  Finally the tech is getting frusterated.  He says the only thing we have changed is that now we send a bounce notification back to the customer.  Before we didn’t do that.  We just blackholed the email.

 

Umm.  Did I hear that correctly.  Cox did not per RFC standards deliver a bounce notification?  They simply deleted emails THAT WERE FROM IT’S OWN CUSTOMERS.

I understand that they have to fight spam etc.  I know that they deal with mostly computer illiterates.  But seriously.  Blackholeing an email, especially one that isnt spam is almost immoral.  Unethical.  And definatley not cool.   Ok you want to have 100% email delivery (yeah right) then you pay a premium for Biz class service. 

Now I can’t tell how many hours I’ve wasted trying to figure out where these lost emails went or who was blocking them etc because a simple notification wasn’t delivered.

 


 

Merge all CSV or TXT files in a folder

Wednesday, May 2nd, 2007

 

Found this cool script to merge a bunch of CSVs into one big one. works great after you use my other post on XLS to CSV convertion.

Ron de Bruin (last update 17 March 2006)
 
1) Non VBA example from Dave Peterson 
2) VBA example I made based on Dave's example
 

Note: with a few small changes you can also use this for tx t files

Change *.csv to *.txt in example 1 and 2 and in the code also use Tab = true

 

Example 1

 

Merge all data from the csv files into a text file


1) Windows Start Button | Run
2) Type
cmd and hit enter ("command" in Win 98)
3) Go to the folder with the CSV files (for help enter "help cd")

4) Type copy *.csv all.txt and hit enter to copy all data in the files into all.txt.

5) Type exit and hit enter to close the DOS window

 

Now we must import the text file all.txt into Excel.

 

1) Open Excel

2) When you use File Open to open all.txt the Text Import Wizard will help you import the file

3) Choose Delimited

4) Next

5) Check Comma

6) Finish

 

 

Example 2
 
This code will ask you to browse to the folder with the csv files and after you click OK in this dialog
it merge all data into a txt file and then import and save it into a Excel file for you.
 
If you want to have more control then you can also use code from this page to open the csv files and copy.
http://www.rondebruin.nl/copy3.htm
Change xls in the code to csv if you want to use it.
 
 
Copy the code below into a normal module of a workbook :
 
Alt-F11
Insert>Module
Paste the macro
Alt q to go back to Excel
Alt F8 to open your macro list
Select Merge_CSV_Files and press Run
 
 
' Start Code
 
Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, _
lpExitCode As Long) As Long
Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STILL_ACTIVE = &H103


Public Sub ShellAndWait(ByVal PathName As String, Optional WindowState)
Dim hProg As Long
Dim hProcess As Long, ExitCode As Long
'fill in the missing parameter and execute the program
If IsMissing(WindowState) Then WindowState = 1
hProg = Shell(PathName, WindowState)
'hProg is a "process ID under Win32. To get the process handle:
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, hProg)
Do
'populate Exitcode variable
GetExitCodeProcess hProcess, ExitCode
DoEvents
Loop While ExitCode = STILL_ACTIVE
End Sub
 
 
Sub Merge_CSV_Files()
Dim BatFileName As String
Dim TXTFileName As String
Dim XLSFileName As String
Dim DefPath As String
Dim Wb As Workbook
Dim oApp As Object
Dim oFolder
Dim foldername
 
    'Create two temporary file names
BatFileName = Environ("Temp") & "\CollectCSVData" & Format(Now, "dd-mm-yy-h-mm-ss") & ".bat"
TXTFileName = Environ("Temp") & "\AllCSV" & Format(Now, "dd-mm-yy-h-mm-ss") & ".txt"
 
    ' Create path to xls file
DefPath = Application.DefaultFilePath
If Right(DefPath, 1) <> "\" Then
DefPath = DefPath & "\"
End If
XLSFileName = DefPath & "MasterCSV " & Format(Now, "dd-mm-yy h-mm-ss") & ".xls"
 
    'Browse to the folder with CSV files
Set oApp = CreateObject("Shell.Application")
Set oFolder = oApp.BrowseForFolder(0, "Select folder with CSV files", 512)
If Not oFolder Is Nothing Then
foldername = oFolder.Self.Path
If Right(foldername, 1) <> "\" Then
foldername = foldername & "\"
End If
 
        'Create the bat file
Open BatFileName For Output As #1
Print #1, "Copy " & Chr(34) & foldername & "*.csv" & Chr(34) & " " & TXTFileName
Close #1
 
        'Run the Bat file to collect all data from the CSV files into a TXT file
ShellAndWait BatFileName, 0
        If Dir(TXTFileName) = "" Then
MsgBox "There are no csv files in this folder"
Kill BatFileName
Exit Sub
End If
 
        'Open the TXT file in Excel
Application.ScreenUpdating = False
Workbooks.OpenText Filename:=TXTFileName, Origin:=xlWindows, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, Comma:=True, _
Space:=False, Other:=False
 
        'Save text file as a XLS file
Set Wb = ActiveWorkbook
Application.DisplayAlerts = False
Wb.SaveAs Filename:=XLSFileName, FileFormat:=xlWorkbookNormal
Application.DisplayAlerts = True
 
        Wb.Close savechanges:=False
MsgBox "You find the XLS file here: " & XLSFileName
        'Delete the bat and text file you have create
Kill BatFileName
Kill TXTFileName
 
        Application.ScreenUpdating = True
End If
End Sub

‘ End code

 

Batch convert XLS to CSV

Wednesday, May 2nd, 2007

Batch convert XLS to CSV.

This worked for me in Excel 2007.  Works great.  I saw software that does this for $19.99 up to $120.99.

After this you can Merge the CSVs into one file. 

Originally posted to a google group by Dave Peterson.


 

Option Explicit
Sub testme01()

    Application.ScreenUpdating = False

    Dim myFiles() As String
    Dim fCtr As Long
    Dim myFile As String
    Dim myPath As String
    Dim tempWkbk As Workbook
    Dim logWks As Worksheet
    Dim tempName As String
    Dim wks As Worksheet
    Dim oRow As Long

    ‘change to point at the folder to check
    myPath = "c:\my documents\excel\test"
    If Right(myPath, 1) <> "\" Then
        myPath = myPath & "\"
    End If

    myFile = Dir(myPath & "*.xls")
    If myFile = "" Then
        MsgBox "no files found"
        Exit Sub
    End If

    Set logWks = Workbooks.Add(1).Worksheets(1)
    logWks.Range("a1").Resize(1, 3).Value _
        = Array("WkbkName", "WkSheetName", "CSV Name")

    ‘get the list of files
    fCtr = 0
    Do While myFile <> ""
        fCtr = fCtr + 1
        ReDim Preserve myFiles(1 To fCtr)
        myFiles(fCtr) = myFile
        myFile = Dir()
    Loop

    If fCtr > 0 Then
        oRow = 1
        For fCtr = LBound(myFiles) To UBound(myFiles)
            Set tempWkbk = Nothing
            On Error Resume Next
            Set tempWkbk = Workbooks.Open(Filename:=myPath & myFiles(fCtr))
            On Error GoTo 0
            If tempWkbk Is Nothing Then
                logWks.Cells(oRow, "A").Value = "Error Opening: " _
                                                      & myFiles(fCtr)
                oRow = oRow + 1
            Else
                For Each wks In tempWkbk.Worksheets
                    With wks
                        If Application.CountA(.UsedRange) = 0 Then
                            ‘do nothing
                        Else
                            .Copy ‘to a new workbook
                            tempName = myPath & Trim(.Name) & ".csv"
                            Do
                                If Dir(tempName) = "" Then
                                    Exit Do
                                Else
                                    tempName = myPath & Trim(.Name) & "_" _
                                          & Format(Time, "hhmmss") & ".csv"
                                End If
                            Loop
                            oRow = oRow + 1
                            With ActiveWorkbook
                                .SaveAs Filename:=tempName, FileFormat:=xlCSV
                                .Close savechanges:=False
                            End With
                            logWks.Cells(oRow, "A").Value = myFiles(fCtr)
                            logWks.Cells(oRow, "b").Value = .Name
                            logWks.Cells(oRow, "C").Value = tempName
                        End If
                    End With
                Next wks
                tempWkbk.Close savechanges:=False
            End If
        Next fCtr
    End If

    With logWks.UsedRange
        .AutoFilter
        .Columns.AutoFit
    End With

    Application.ScreenUpdating = True

End Sub

If you’re new to macros, you may want to read David McRitchie’s intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:
Start a new workbook
Hit alt-f11 to get to the VBE (where macros/UDF’s live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like:   VBAProject (yourfilename.xls)  

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.  

Modify the folder that contains the .xls files.
myPath = "c:\my documents\excel\test"
to what you need.

Now go back to excel.
Save your workbook (so you can run the macro)

When you want to run or rerun:
Open this workbook
(fix the folder name in the code if it changed)

click on Tools|macro|macros…
click on the macro name (testme01, but you can rename it!)
and then click run.