Virtual Earth 6.1 SDK - Context Menu

by Syska 20. August 2008 01:02

Google is the first one to do many things on the internet, and the others just follow ... and so did Microsoft here:

Made it possible to search the world in a virtual map ... but with different views of the earth and how it looks today. I won't be going into detailt about, seach for live maps or google maps if you want to know more detailts about it.

Google's: http://maps.google.com/
Microsoft: http://maps.live.com/

I havent used any of them very much, but was asked if I create a little site taking advantage of Live maps from Microsoft.

Links of interrest:
Microsoft Virtual Earth - here you can find all you need to get started, but I will still point out some of the resources I have used.

Virtual Earth JavaScript Intellisense Helper - very nice, helped me alot during my exploration though of it.

Creating a Context Menu to support additional options to Virtual Earth/Live maps

1st step

The example is taken from: Virtual Earth Interactive SDK

Create a html document with the following.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head> <title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1"></script>
<script type="text/javascript">
var map = null;
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap();
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
</body>
</html>

2nd step

Add the following to the GetMap() fucntion:

map.AttachEvent("onclick", ShowPopupMenu);

3rd step

Add the following html to the file ( just above the myMap div would be fine ):

    <div id="menu">
        <ul id="popupmenu" class="pmenu">
            <li><a href="#" onclick='RemovePopupMenu(); alert("First");'>First</a></li>
            <li><a href="#" onclick='RemovePopupMenu(); alert("Second");'>Second</a></li>
            <li><a href="#" onclick='RemovePopupMenu();'>Exit</a></li>
        </ul>
    </div>

4th step

Add the following function to the java-script block:

function ShowPopupMenu(e) {
    if (!e.rightMouseButton) {
        RemovePopupMenu();
        return;
    }

    var menu = document.getElementById('popupmenu');

    menu.style.display = 'block'; //Showing the menu
    menu.style.left = e.clientX + "px"; //Positioning the menu
    menu.style.top = e.clientY + "px";
}

function RemovePopupMenu() {
    document.getElementById("popupmenu").style.display = 'none';
}

5th step

Add some css style after the <meta> tag in the top of the html document:

<style type="text/css" media="screen">
    ul, li {margin:0;padding:0;}

    ul.pmenu
    {
        display: none;
        position:absolute;
        margin: 0;
        padding: 1px;
        list-style: none;
        width: 150px; /* Width of Menu Items */
        border: 1px solid #ccc;
        background: #235087;
        z-index:10;
    }

    ul.pmenu li { position: relative; }

    ul.pmenu li a
    {
        display: block;
        text-decoration: none;
        color: White;
        padding: 2px 5px 2px 20px;
    }

    ul.pmenu li a:hover
    {
        background:#335EA8;
        color:white;
    }
</style>

Live Demo

You can watch a live demo of it here: http://ifyoudo.net/demo/ve/

Done

Thats all ... there are alot of other examples out on the internet, when I was searching for it, but they all used some earlier versions of the Virtual Earth SDK, and did not work with the current version when I was writing this.

I hope you will find this usefull, please contact me if there are any questions.

Tags: , , , , ,

Project

MailScannerWatermark Plugin For Microsoft Exchange 2007

by Syska 7. August 2008 19:42

If you have more offsite Exchange 2007 installations and dont want to route all mail traffic to the MailScanner box itself to save bandwidth, this is the perfect solution.

Please contact me if there are any missing options in the implementation.

Index

  • How to install the MailScannerWatermark plugin for Microsoft Exchange 2007
  • How to uninstall a TransportAgent for Microsoft Exchange 2007
  • Conclusion
  • Files

How to install the MailScannerWatermark plugin for Microsoft Exchange 2007

File are placed in the bottom.

1st step

Extract the content of the zip archive. The content should look something like below.

Filestructure

  • MailScannerWatermark 
    • AgentProject ( source code )
    • MS Files
      • Microsoft.Exchange.Data.Common.dll
      • Microsoft.Exchange.Data.Transport.dll
    • Files
      • Create.Event.Source.ps1
      • MailScannerWatermark.dll
      • Settings.reg
Copy "MailScannerWatermark.dll" from the "Files" directory to a folder on the Microsoft Exchange 2007 server. I have used "C:\IfYouDo.Net\" and placed the file there. You may use whatever directory you want.

2nd step

Install the plugin with the following command in the Power Shell:

[PS] C:\>install-transportagent

cmdlet install-transportagent at command pipeline position 1
Supply values for the following parameters:
Name: MailScannerWatermark
TransportAgentFactory: IfYouDo.Net.MailScannerWatermarkFactory
AssemblyPath: C:\IfYouDo.Net\MailScannerWatermark.dll

Identity                                           Enabled         Priority
--------                                           -------         --------
MailScannerWatermark                               False           10
WARNING: Please exit Powershell to complete the installation.
WARNING: The following service restart is required for the change(s) to take
effect : MSExchangeTransport


Notes:

  • The AssemblyPath must to changed acordingly to the FolderPath used in step 1.
  • Make sure the permissions are right on the assembly file else it will complain about the Path are incorrect.

3rd step

Enable the plugin in Power Shell with:

[PS] C:\>Enable-TransportAgent MailScannerWatermark

4th step

In the folder used above, there should be a file named "settings.reg", double click it to register the values to the register database and then edit the values or do it manualy before with notepad or similar program:

Change the values to suit your needs:

 Debug  True/False
 HeaderName  HeaderName used in the MailScanner installation, excluding the ":" (colon). The HeaderName will be trimmed for any ":" in the end, just to make sure no one just copies the HeaderName from the MailScanner settings.
 Secret  The secret used in the Mailscanner installation, if MultipleDomains are "False"
 Expiry  How many days the Watermark is valid.
 MultipleDomains  True/False. If "True", it will look for the domain in the regdb, and use that secretkey if found. If the domain is not found, and "Secret" is in the regdb it will use that secretkey else it will just skip that domain. If "False" it will use "Secret" value as key for all doamins.
 domainname.tld  secretkey

Example 1 - Same secret for all domains.

Example 2 - domain1.com and domain2.com have diff keys but "Secret" are used for all others

Remove the "Secret" key from the regdb, if you dont want other domains than domain1.com and domain2.com to get tagged with a Watermark.

5th step

Run the following command in the Power Shell to restart the Microsoft Exchange Transport.

[PS] C:\>Restart-service MSExchangeTransport

6th step

Run the "Create.Event.Source.ps1" from the Files folder, this will create an EvenLog Source "MailScannerWatermark" in the Application log.

7th step

First ... use debug ... there will be  some info about the time found, msgid, etc. so we know its right.

Then send an email to a valid recipient, to see that the watermark is actually there.
Then send an email to an invalid recipient, that you know will send a message back to you, and make sure its get a NDR.
Then telnet to a public ISP SMTP server, and make a fake email, that we know will not get a valid watermark.

All text below with a "C:" before the line are client commands, and needs to be written by you, the others are server responses.

Make a "telnet" connected to a smtp. Like the below if you are running Windows. The prompt may differ a little.
cmd> telnet some.smtp.tld 25
S: 220 smtp.example.com ESMTP Postfix
C: HELO relay.example.org
S: 250 Hello relay.example.org, I am glad to meet you
C: MAIL FROM:<bob@example.org>

S: 250 Ok
C: RCPT TO:<alice@example.com>
S: 250 Ok
C: RCPT TO:<theboss@example.com>
S: 250 Ok
C: DATA
S: 354 End data with <CR><LF>.<CR><LF>
C: Subject: Test message
C: Hello Alice.
C: This is a test message
C: Your friend,
C: Mikael Syska
C: .
S: 250 Ok: queued as 12345
C: QUIT
S: 221 Bye


The above example should be with a valid from address and an invalid recipient address, so we will get a NDR, but this time it should be taken by the MailScanner server, since it does not contain a valid Watermark.

How to uninstall a TransportAgent for Microsoft Exchange 2007

1st Step

Will give you a list of all installed transportagents

[PS] C:\>transportagent
Identity                                           Enabled         Priority
--------                                           -------         --------
Transport Rule Agent                               True            1
Journaling Agent                                   True            2
Connection Filtering Agent                         True            4
Content Filter Agent                               True            5
Sender Id Agent                                    True            6
Sender Filter Agent                                True            7
Recipient Filter Agent                             True            8
Protocol Analysis Agent                            True            9
MailScannerWatermark                               True            10


2nd Step

From the list above, I have choosen to uninstall the "MailScannerWatermark" plugin.

[PS] C:\>uninstall-transportagent MailScannerWatermark

Confirm
Are you sure you want to perform this action?
Uninstalling Transport agent "MailScannerWatermark". A service restart is
required for the change to take effect.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "Y"):


Type "Y" to confirm that you want to uninstall it

3rd Step

Run the following command in the Power Shell to restart the Microsoft Exchange Transport.

[PS] C:\>Restart-service MSExchangeTransport

Now the plugin is uninstalled from the system.

Conclusion

This have been very fun to play with Microsoft new Transport-Agents in Exchange 2007. There are very powerfull and there are endless ideas of what you can do now ... in a very easy way compared to Event Sinks in Exchange 2003.

Any comments are most welcome ...

Note: This could be made to work with EventSinks also in Exchange 2003, but I dont have the knowledge nor time to do it ... if someone makes it, I will happily post it here.

Files

Old version will be taken offline and will not be available.

Version Download Changes
v.2 MailScannerWatermark.zip (617.01 kb) Updated to support multiple "Secrets"
v.1 MailScannerWatermark.zip (612.53 kb) First version

Tags: , , , , ,

Project

About the brain

Mikael SyskaMikael Syska

Student at the Engineering College of Aarhus.

Microsoft Student Partner ( MSP )

On this blog I will primarily write about .NET, MSSQL & projects I'm working on ... and of course there will some off topic posts :-)