Get your External IP address in a batch process (command line)

If you are familiar with the frustration where you need your External IP address and the only way to do it (you think) is to open your browser and navigate to whatismyip or a similar, this post might do you good.

In this post, we will do several things:
1. We will learn how to create our own simple developing environment.
2. We will compile a very basic command line application (don’t worry I will provide the source)
3. We will use that new application for our needs (discover what is our external IP in a batch program - we will use those web sites but not in a browser)

So let’s begin,
Software we need:
a. Jens’ File Editor
b. BCX – Basic to C Translator/
c. LCC – C Compiler/
d. Source Files

After installing that precious software, let’s configure them to work with each other,
Open the JFE editor, add the BCX translator, LCC Compiler, LCC Linker buttons to it:
Go to “Settings --> Add tool”

JFE Editor - Settings - Add tool

Add those 3 tools:
BCX Button

LCC Compile Button

LCC Link Button

(Parameters for the link button:
"$PATH\$NAME.obj" -s -output:"$PATH\$NAME.exe" -subsystem:console wsock32.lib wininet.lib urlmon.lib shell32.lib)

For me, JFE looks like this (our small source code already opened in it):
JFE opened with the IPEX source in it

If you have not done it already, please open the source file IPEX.BAS
(Download the ZIP from here)

Take this great offer valid until 07/11/09

Microsoft Store

Now we will translate it to C source, just click the BCX button you have created earlier:
BCX Output Log at JFE

Drag your new “IPEX.C” file into JFE:
IPEX C Source opened at the JFE Editor

Click the “LCC Compile” button, verify no error at the log, and click the “LCC Link Con” button.

You should have the following files now:
Final File list after compile and link

All you have to do now is to use it:
IPEX Usage example at the command line

You can combine it with an email batch sending application (and maybe a schedule task) that will send you a message once a day with your home/office external IP (for dynamic IP’s) or any command line combination you want.



Outlook Plug-in: External Watch - Get Alert when a message is designate outside your organization.

Have you ever asked yourself how can you alert your CEO that the message s/he is about to Reply (Reply All - 28 recipients...) is about to fly out from your organization Exchange Server to another company's mail servers?

Well if you did, then here is a simple way to do so:

I have created a simple Add-in for Microsoft Outlook (2000, 2003, and 2007) for this single purpose.
Let's see how it works:

  • Your Exchange user is receiving a message that requests him to reply-all with a sensitive business data.

outlook new message arrival

outlook message header
  • S/He then clicks the reply all button.

outlook message header and reply all
(In a single recipient message, it is easy to see the problem, but what about the 28 recipient messages that your CEO almost replied to)

  • And add the information requested at the mail:

the sensitive data at the outlook message
  • S/He clicks the Send Button.

external watch plugin - main alert

As you can see, there is now a modal message that indicates that the message designated outside the company.

You can now return to the message and remove/replace the problematic recipient/s, or click the "More Details" button to find the problematic recipient/s.

external watch - more details view

It could be that you are aware that your message is designate to third party recipient/s; in this case, it is not a problem, just show the add-in that this is your intention and add to the end of your subject the phrase: "$OUTSIDE$", the add-in will not ask you anything and will just sent the message immediately.
(The "$OUTSIDE$" will be remove from the subject before sending the message)

external watch - modified subject

How to Install:
1. Download the add-in archive from Here
or visit my Google group Home
2. Extract the archive.
3. Copy the File "olkExternalWatch.dll" to your system32 folder ("C:\windows\system32\")
4. Register it using the regsvr32.exe - "Regsvr32.exe c:\windows\system32\olkExternalWatch.dll"
5. Restart your outlook.
(I've made a batch file that will do all the tasks above for you in a one click - "install.bat")

Thanks to Yuval Malachi that gave me the idea of creating the same plug-in but without the "$OUTSIDE$" thing (or as we called it - warn only mode)
you can download the Warn only mode here

A screen shot of the new version:

External Watch - Warn Only mode

How to Disable:

Outlook 2007:
Tools Menu - Trust Center - Add-ins - Com Add-ins - Go
outlook 2007 Com Add-ins manage

Unchecked the "ExtrenalWatch" check box.

Outlook 2007 Com add-ins enable/disable

Outlook 2003:
Tools Menu - Options - Other Tab - Advanced Options - Com Add-ins
Outlook 2003 Com Add-ins manage

Unchecked the "ExtrenalWatch" check box.

Outlook 2003 Com Add-ins Enable/Disable

How to uninstall:
Just unregister it using the regsvr32.exe - "Regsvr32.exe c:\windows\system32\olkExternalWatch.dll /u" and restart your outlook.

Hope you will find it useful.


Use a VBA Macro inside an Excel Cell

This post will explain to all the Excel fans out there (not the big shot developers, just the sophisticated users among us) how to create a simple macro within Microsoft Excel, and then how to use that macro to calculate a single cell value.

Ok, Let's improve our worksheets with the VBA excel macros:

(Don’t forget to enable Macros now)

  • Open the VBA Editor (Alt-F11).

  • Add a new module (or use your existing module)

excel vba interface - add module to project

Our macro will encrypt a text (very simple - just for the example, don't use it for your applications, click here for advanced encryption methods).

  • Let’s add the next function to the code:

Function enconeway(ByVal TextToEncrypt As String) As String
Dim tmp As String
Dim cnt As Integer
For cnt = 0 To Len(TextToEncrypt)
tmp = tmp & Asc(Mid(TextToEncrypt, cnt, 1))
tmp = StrReverse(tmp)
enconeway = tmp
End Function

  • Now let’s use it:

vba cells - macro usage

  • Create a word list, and near that list just edit the first cell as seen at the picture above.

Vibe Red 200x200

This is the outcome:

vba worksheet with all the cells using the macro

A short Video to show the process visually:

I've found a great site with alot of screen shots and examples (mainly about how to use the VBA environment), there is also a complete course you can take there, so go ahead and take a look.

That’s it folks, very easy and very fast, now go ahead and kick some macros…

Oh: don’t forget to save you’re excel as a macro enabled workbook.
excel macro enabled worksheet

If you've never owned an Excel package, maybe now is a good time to purchase one..

Microsoft Store

Outlook - Print all attachments at once (or: Handle attachments with VBA)

* Update for Outlook 2010/2013 users: there is a new plugin that can do all of the below code without any code writing, Download it here :

If you want to have the ability to print all the attachments (from a mail item) at once, than this post is for you (also if you just want to know how to handle attachments using VBA in Outlook):

This post content is only to show you how to handle attachments in a VBA code , you can print your attachments in many other ways as well, but here you can learn how to do outlook VBA attachments handling

(this post's screen shots were taken from Microsoft Outlook 2003)

The instructions:

Outlook -> Click Alt-F11 to open the VBA Editor

Or use “Tools” Menu - “Macro” - “Visual Basic Editor”

outlook VBA attachments handling

Right Click The "Project1" Line And Select Insert Module

outlook VBA attachments handling

In the new added module (if it’s your first module then it is named by default “Module1”) paste the following code:

AVG products are running on over 80 million computers worldwide, find out why.

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub printall()
Dim CurrentMailItem As MailItem
Dim attCounter As Integer
Dim loopCounter As Integer
Dim attFileName As String
Dim errMsg As String
On Error GoTo err
CurrentMailItem = Application.ActiveInspector.CurrentItem
attCounter = CurrentMailItem.Attachments.Count
For loopCounter = 1 To attCounter
attFileName = CurrentMailItem.Attachments.Item(loopCounter).FileName
CurrentMailItem.Attachments.Item(loopCounter).SaveAsFile( _
Environ$("TEMP") & "\" & attFileName)
ShellExecute(0, "print", Environ$("TEMP") & "\" & attFileName, "", "", 1)
Kill(Environ$("TEMP") & "\" & attFileName)
Exit Sub
IIf(attFileName <> "", errMsg = "Last file handeld was : " & _
attFileName & ".", errMsg = "No file was handeld.")
MsgBox("Error printing all attachments." & vbCrLf & errMsg & _
vbCrLf & vbCrLf & err.Description, vbCritical, "Error number " & _
End Sub

You can download the module from here (for "Copy-Paste" issues)

Save the module and Close the VBA Editor.
Open any received mail message.
Right Click one of the toolbars and select “Customize…”

Outlook toolbar customize macro

Drag the “Project1.printall” Macro to one of your toolbars

Outlook toolbar customize macro

Change the new button name and icon

Outlook toolbar customize macro

Close the message.
here ends the "Outlook toolbar customize macro" thing

How to use it:
Open the message with the attachments
Click your new button and all your attachments (at the current opened item) will wait for you at your printer tray.

Pay attention:
You will print only to the last printer used by outlook.