Friday, July 27, 2007

Outlook Consumes 100% CPU and Stuck at 99% Send/Recieve

For a long time I had a problem where my Outlook client would get stuck at 99% Send/Recieve and at the same time consume 100% (or as much as it can) CPU.

I have two different computers (XP and Vista) running Outlook 2007 against Exchange 2007 (Hosted Exchange) wich had the exact same problem.

When I looked at the Send/Recieve Details it usually said something like "Synchronizing Hierarchy" or just "Updating Inbox". If I did Cancel Send/Recieve the CPU went down to normal.

After looking at the Synchronization Log messages in the Sync Issues folder I found a zillion messages like this:

08:46:56 Synchronizer Version 12.0.4518
08:46:56 Synchronizing Mailbox 'Max Flodén'
08:46:56 Synchronizing Hierarchy
08:47:09 Synchronizing server changes in folder 'Inbox'
08:47:09 Downloading from server 'ex2.myisp.se'
08:48:02 69 item(s) added to offline folder
08:48:04 Synchronizing server changes in folder 'Deleted Items'
08:48:04 Downloading from server 'ex2.myisp.se'
08:48:05 Done
08:48:20 Microsoft Exchange offline address book
08:48:20 Not downloading Offline address book files. A server (URL) could not be located.
08:48:20 0X8004010F


So, the problem seemed to be with the Offline Address Book (OAB).

To make a long story short - after working back and forth with my Hosted Exchange ISP, Googling, creating and recreating Outlook profiles etc - the solution turned out to be that I needed to add a DNS entry for my domain in order for Outlook to Autodiscover which was the problem all along.

Autodiscover CNAME autodiscoverredirect.myisp.se

After adding this DNS entry for my domain it did not even take a minute before I got a dialog box asking me "Allow this website to configure max.floden@mydomain.se server settings?"


And that was it - no more stuck at 99% and no more Outlook consuming all CPU. Finally!

[Update: Found a Microsoft Knowledge Base article that describes this in more detail: A new feature is available that enables Outlook 2007 to use DNS Service Location (SRV) records to locate the Exchange Autodiscover service ]

Labels:

Wednesday, July 25, 2007

Outlook and outgoing SMTP servers

I have just moved and changed my ISP to one that not only blocks port 25 but also only allows their SMTP relay server to be accessed from within their own network.

When I'm at home with my laptop I have set my outgoing SMTP server as smtp.myhome-isp.com and all is fine. But when I want to work out of my office I have to change it (for all my seven accounts) to smtp.myoffice-isp.com.

I looked and asked around for some smart solution to this problem but found none except the advice to setup my own mailserver or subscribe to a mailserver service.

So, I did the same thing that I did years back when I had the same ISP (and the same problem) - I created two hosts files where I put the IP adresses to respective ISP's SMTP relay servers. (The hosts file is where your computer goes before it goes out to the DNS to lookup an ip adress.)
  1. Goto c:\windows\system32\drivers\etc and make two copies of the hosts file and call them for example hosts.myhome-isp and hosts.myoffice-isp


  2. Edit the files and add an entry to each file for your home and office isp's SMTP relay servers and add the hostname as mailout. You have to enter the IP address of the SMTP relay server (eg 10.10.10.1 not smtp.myhome-isp.com) if you don't know it do a ping or nslookup to find out.


  3. On the desktop (or a location of your choice) create two new batch files, eg. MyHome ISP SMTP.cmd and MyOffice ISP.cmd and add these three lines of code to each:

    cd c:\windows\system32\drivers\etc\
    copy hosts.myhome-isp hosts
    pause

    (Line two above should read "copy hosts.myoffice-isp hosts" for MyOffice ISP.cmd)


  4. In Outlook set outgoing SMTP server to mailout

Whenever you move from home to the office run MyOffice ISP.cmd and vice versa. It may not be the ultimate solution but it works (at least for Outlook 2003 and 2007)

Labels:

Tuesday, March 27, 2007

Things I can and cannot get to work in Vista and Office 2007

I just upgraded my laptop running XP to Office 2007 and I've also started using my new desktop computer running Vista and Office 2007.

These are a few things that have bugged me and how I made them work (or not):

1) I could no longer run my macros in Outlook 2007.
Whenever I went in to Tools - Macro - Macros, selected my macro and hit run I would end up in the Visual Basic editor with an error message saying "The macros in this project are disabled. Please refer to the online help or documentation of the host application to determine how to enable macros."
I went in to Tools - Macro - Macro Security and first changed from the default "Warnings for signed macros; all unsigned macros are disabled" to "Warnings for all macros" and finally to "No security check for macros" but I still could not get the macros to run.
In spite of a lot of Googling I found nothing. Then I realized I hadn't tried trick no 1 in the book: Restart Outlook. And of course that was the solution. ;-)
(Note to Microsoft: Please add a "Outlook needs to be restarted" message. Note to myself: Don't be so stupid next time around)

A good thing in Outlook 2007 is that I no longer get the "A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? ... Allow for x minutes". I assume they have gotten rid of this annoying message and replaced with some security feature that does not require user intervention.

2) Desktop Search 3.0 had my hard drive indicator constantly lit up for 24 hours
After installing Office 2007 on my laptop I activated the built-in search functionality which requires me to download and install Windiows Desktop Search (WDS) 3.0.
After installing WDS my hard drive starts working overtime with the hard disk indicator constantly lit. Needless to say working with any programs is very slow or does not work at all.
I Googled the processes searchindexer.exe and searchprotocol.exe and get the advice to shut down the Windows Search service but it restarts after awhile. After trying various things I figure that maybe it just needs to finish indexing and almost 24 hours later the hard drive indiciator finally goes blank and my 85000+ documents (according to the WDS Indexing status window) are indexed.

So the problem was that 1) the indexing is slow, and 2) it takes up too much resources when you're using the computer (in my case a Celeron laptop running XP with 1.5GB memory).

As I remember it, WDS 2 it only ran when you were not using the computer at all. WDS 3 runs all the time even though the Indexing status window says "Indexing speed is reduced while you use your computer". There really should be more settings when you want WDS to run.

Big plus for WDS 3 though: It works! :-) At least this far. WDS 2 did not (see previous posts).

3) I cannot Copy and Paste files to/from Remote Desktop (RDC) when I'm running Vista
Copy and Paste of text works fine. My remote server is running Windows 2003. My guess is this has to do with some new fancy security setting in Vista but I have not yet found a solution. Any tips are greatly appreciated.
[Update: I got it working, and I think this is actually the way it works in XP too: You need to share a drive to make drag/drop or copy/paste of files work. When you start Remote Desktop, before you connect, click Options - Local Resources - More and then check Drives.]

Labels: , ,

Thursday, February 15, 2007

Newsletter Unsubscribe and Delivery Failure in Outlook

I have a web site from which I weekly send out newsletters to 15-20.000 members. The sending of the newsletters is fully automated but I use two VBscript Macros in Outlook to handle Delivery Failures (eg. User Unknown, Domain not Found, Mailbox Full) and the manual Unsubscribe Requests I get. I know I can buy or subscribe to tools that automate this for me but I find it easy enough to handle it manually in Outlook using these two Macros. Nothing fancy or hitech but maybe it helps someone else out.

The Macros are written in VBscript and used in Outlook 2003. I have not yet tested them in Outlook 2007 but I expect they will work there too. (I have just installed a new computer with Windows Vista and Office 2007 but have not yet had the time to move everything there)

How I use the Macros:
  1. Newsletters are automatically sent to members
  2. Delivery Failures and Unsubscribe emails land in my Outlook Inbox and I move them to a Errors and Unsubscribe folder respectively (I could/should create an inbox rule that based on recipient automatically move them to the correct folder)
  3. I run the Macros to extract email addresses
  4. I paste the extracted email addresses into a admin page that I have created for my site that remove them from the database, send a confirmation email etc.
Script 1 - GetEmailSender:
Extracts email sender. Runs on all mailitems in current folder that are unread. This is the Macro I run on Unsubscribe emails.
[Update: Download this macro as a text file here.]

Script 2 - GetEmailFromBody:
Extracts first found email address from body. Runs on all items in current folder. This is the Macro I run on Delivery Failure emails.
[Update: Download this macro as a text file here.]


(To add the Macros in Outlook: Copy code from below, goto to Tools - Macros - Visual Basic Editor - and paste the code there)

Sub GetEmailSender()

' ------------------------------------------------
' --- You may use and/or change this code freely
' --- provided you keep this message
' ---
' --- Description:
' --- Extracts email sender
' --- Runs on all mailitems in current folder that
' --- are unread
' ---
' --- By Max Flodén 2006 - http://www.tjitjing.com
' ------------------------------------------------

Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace

Dim mySelection As Selection

Dim myItem As Object
Dim myMailItemLog As Outlook.MailItem

Dim myFolder As Outlook.MAPIFolder

Dim strContactFolderName As String 'Directly under Public Folders\All Public Folders
Dim strNewsletterCategoryName As String
Dim strMailItemSender As String
Dim strMailTo As String
Dim intMessageCount As Integer
Dim bolDebug As Boolean 'If true error messages will be shown
Dim strTemp As String

Set myNameSpace = myOlApp.GetNamespace("MAPI")

'Debug settings
bolDebug = True

'Ask to continue - start warning
intRes = MsgBox("This macro will go thru all items in folder." & vbCrLf & "Would like to continue?", vbYesNo + vbQuestion, "Get Email Sender")
If Not intRes = vbYes Then Exit Sub

'Create a new email to use as log file
Set myMailItemLog = myOlApp.CreateItem(olMailItem)
myMailItemLog.Recipients.Add (myNameSpace.CurrentUser)
myMailItemLog.Subject = "Email from Body - " & Now()
myMailItemLog.BodyFormat = olFormatPlain
myMailItemLog.Body = Now() & " Starting..." & vbCrLf & vbCrLf

'Go thru all items in folder
intMessageCount = 0
intMsgCount_Error = 0
For Each myItem In myOlApp.ActiveExplorer.CurrentFolder.Items

If Not TypeName(myItem) = "MailItem" Then
'Errorlog
If bolDebug Then myMailItemLog.Body = myMailItemLog.Body & "ERROR - MESSAGE TYPE IS NOT MAILITEM." & vbCrLf
myItem.UnRead = True
intMsgCount_Error = intMsgCount_Error + 1
ElseIf myItem.UnRead Then
myMailItemLog.Body = myMailItemLog.Body & myItem.SenderEmailAddress & vbCrLf
myItem.UnRead = False
myItem.FlagStatus = olFlagMarked
intMessageCount = intMessageCount + 1
End If

Next

'Done - write to log and show done message
myMailItemLog.Body = myMailItemLog.Body & vbCrLf & Now() & " Done. Email addresses extracted: " & intMessageCount & ". Email addresses NOT extracted: " & intMsgCount_Error & "."
myMailItemLog.Display
MsgBox Now() & " Done. Email addresses extracted: " & intMessageCount & ". Email addresses NOT extracted: " & intMsgCount_Error & ".", vbInformation, "Done"

End Sub



Sub GetEmailFromBody()

' ------------------------------------------------
' --- You may use and/or change this code freely
' --- provided you keep this message
' ---
' --- Description:
' --- Extracts first found email address from body
' --- (used to extract email address from
' --- error messages/returned email)
' --- Runs on all items in current folder
' ---
' --- By Max Flodén 2006 - http://www.tjitjing.com
' ------------------------------------------------

Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim mySelection As Selection
Dim myItem As Object
Dim myMailItemLog As Outlook.MailItem
Dim myFolder As Outlook.MAPIFolder

Dim strContactFolderName As String 'Directly under Public Folders\All Public Folders
Dim strNewsletterCategoryName As String
Dim strMailItemSender As String
Dim strMailTo As String
Dim intMessageCount As Integer
Dim bolDebug As Boolean 'If true no emails will be sent
Dim bolOnly550 As Boolean 'Only extract email addresses that are 'user not found' (#550) etc.
Dim strTemp As String

Set myNameSpace = myOlApp.GetNamespace("MAPI")

'Debug settings
bolDebug = True

'Ask to continue - start warning
intRes = MsgBox("This macro will go thru all items in folder." & vbCrLf & "Would like to extract only addresses that have 'user not found'?", vbYesNoCancel + vbQuestion, "Get Email from Body")
If intRes = vbCancel Then
Exit Sub
ElseIf intRes = vbYes Then
bolOnly550 = True
Else
bolOnly550 = False
End If

'Create a new email to use as log file
Set myMailItemLog = myOlApp.CreateItem(olMailItem)
myMailItemLog.Recipients.Add (myNameSpace.CurrentUser)
myMailItemLog.Subject = "Email from Body - " & Now()
myMailItemLog.BodyFormat = olFormatPlain
myMailItemLog.Body = Now() & " Starting..." & vbCrLf & vbCrLf

'Go thru all items in folder
intMessageCount = 0
intMsgCount_Error = 0
For Each myItem In myOlApp.ActiveExplorer.CurrentFolder.Items

If Not TypeName(myItem) = "ReportItem" And Not TypeName(myItem) = "MailItem" Then
'Errorlog
If bolDebug Then myMailItemLog.Body = myMailItemLog.Body & "ERROR - MESSAGE TYPE IS NOT REPORTITEM OR MAILITEM." & vbCrLf
myItem.UnRead = True
intMsgCount_Error = intMsgCount_Error + 1
Else

'Check type is 550 - user not found/inactive etc
If bolOnly550 And _
(InStr(myItem.Body, "550") = 0) And _
(InStr(myItem.Body, "554") = 0) And _
(InStr(myItem.Body, "unknown user") = 0) And _
(InStr(myItem.Body, "user unknown") = 0) And _
(InStr(myItem.Body, "no mailbox here by that name") = 0) And _
(InStr(myItem.Body, "no such user") = 0) And _
(InStr(myItem.Body, "bad address") = 0) And _
(InStr(myItem.Body, "Host or domain name not found") = 0) And _
(InStr(myItem.Body, "e-mail account does not exist") = 0) Then
If bolDebug Then myMailItemLog.Body = myMailItemLog.Body & "ERROR - NOT 550 OR Host or domain name not found MESSAGE." & vbCrLf
myItem.UnRead = True
intMsgCount_Error = intMsgCount_Error + 1
Else

'Extract email address from body
intPos = InStr(myItem.Body, "@")
If intPos = 0 Then
'No email address found
If bolDebug Then myMailItemLog.Body = myMailItemLog.Body & "ERROR - NO EMAIL ADDRESS FOUND IN MESSAGE." & vbCrLf
myItem.UnRead = True
intMsgCount_Error = intMsgCount_Error + 1
Else
'Get right of @
intPos_Space = InStr(intPos, myItem.Body, " ")
intPos_Bracket = InStr(intPos, myItem.Body, ">")
If (intPos_Space < intpos_bracket =" 0)" intpos_temp =" intPos_Space" intpos_temp =" intPos_Bracket" strtemp =" Left(myItem.Body," intpos_space =" InStrRev(strTemp," intpos_bracket =" InStrRev(strTemp,"> intPos_Bracket) Or (intPos_Bracket = 0) Then
intPos_Temp = intPos_Space
Else
intPos_Temp = intPos_Bracket
End If
strTemp = Mid(strTemp, intPos_Temp + 1)
'Write to log
myMailItemLog.Body = myMailItemLog.Body & strTemp & vbCrLf
myItem.UnRead = False
intMessageCount = intMessageCount + 1
End If
End If
End If

Next

'Done - write to log and show done message
myMailItemLog.Body = myMailItemLog.Body & vbCrLf & Now() & " Done. Email addresses extracted: " & intMessageCount & ". Email addresses NOT extracted: " & intMsgCount_Error & "."
myMailItemLog.Display
MsgBox Now() & " Done. Email addresses extracted: " & intMessageCount & ". Email addresses NOT extracted: " & intMsgCount_Error & ".", vbInformation, "Done"

End Sub

Labels:

Friday, October 27, 2006

Things I miss from Notes in Outlook + Desktop Search for Lotus Notes released

I used Lotus Notes as email client for many years, starting with Notes R2 up to R6, and for the last 3 years I've been using Outlook 2003. Both have their pro's and con's. When I started using Outlook I loved the UI and the Office integration. But there are (at least) two things I miss from Notes:

1) The All view
This is the view where you see ALL your emails - recieved, sent, drafts. With this view you don't really need your inbox, sent folder etc (though Notes have these too).
What I miss is for example when you email someone back and forth, you want to delete everything but the last email since you already keep the email history in each email. With Outlook you have to switch between the inbox and the sent folder. Of course you can't bother to do so, so your sent folder gets full of thousands and thousands of useless emails that should have been deleted.
You can probably build this view yourself in Outlook, I did give it a quick try a year or two ago but failed. If you know how to do this please let me know...!

2) Full-text indexing
This is my all time favourite, Notes have had this ever since I started using it in R2 (at least I think so). Anyone who uses Google Desktop or Microsoft Windows Desktop Search (WDS) knows what I'm talking about. No more looking through folders and scroll thousands of emails in search for that email about that thing from that guy who's name you can't really remember...
The big difference is that Notes full text indexing works and is superfast. I don't know what's wrong with Google Desktop and Desktop Search but it just does not index all my email no matter how I rebuild indexes, reinstall and follow various other tips and tricks found on the net.
For exampel if I search for any email containing the word "logo" (of which I have many) Desktop Search just keeps telling me "Nothing found in All locations for query "logo". While other searches seems to be working fine. It's just unreliable which Notes full text search never was.

I haven't looked that much at Office 2007 yet so maybe these things will be solved there (but somehow I doubt that). The thing about Office 2007 that I personally look forward to the most is the improved use of tasks in Outlook 2007, where tasks will show up on your daily calendar. If they just fix tasks in Windows Mobile Smartphone edition everything will be great ;-) (as blogged about elsewhere...)

Windows Desktop Search Add-in for Lotus Notes
Speaking of full text indexing I just saw that Microsoft released a Lotus Notes add-in for Desktop Search. It should work for Notes R5 and up but only seems to index selected Notes databases:

The Windows Desktop Search Add-in for Lotus Notes is a protocol handler that allows you to index the conent of Lotus Notes email, contacts, calendar items, and journal items stored on your computer.


Ps: Three blog posts in two days! This is a new record for me :-)
I was going to write about my wife's brand new Sony Ericsson Z610 which seems to be a great phone but we can't figure out what some of the icons on the screen mean and the manual does not have a single page explaining what is going on on the screen(!) Also the external screen does not show when a new text/SMS message has arrived for more than a few seconds. After that you have to open the phone to check the internal screen to see if there were any messages while you were gone. Or maybe it's just a setting but I cannot find it... Well, that will have to be in another post.

Labels: ,