Emailing Map Images…

So – I need to facilitate emailing a map from a custom .NET ArcIMS site. (built on DotNetNuke – screen shot below)

 In .NET we conventiently have the System.Web.Mail namespace and objects to help out with this. It’s almost trivial to use…

Dim Email As New MailMessage
Email.To = “address@something.com
Email.From = “from@something.com
Email.Subject = “Hello”
Email.Body = “This is the email.”
SmtpMail.SmtpServer = “localhost”
SmtpMail.Send(Email)

The issue is how to attach a map. There is an
Attachemet object, but it only supports attaching FILES. So you say -
big deal - ArcIMS has created a .gif file, just send that. Well,
that’s cool if ArcIMS is on the same physical machine as the .NET app,
or if you can map a drive to ArcIMS’s output location, but what happens
when that’s not possible? i.e. you need to retreive the map from the
output location, and then attach it. Ideally you do this by loading the
image from the URL using a WebClient object (this is easiest, maybe not
fastest)…

Dim webC As WebClient = New System.Net.WebClient
Dim OutputBitmap As Bitmap = New Bitmap(webC.OpenRead(

))

Great. Now I can save the bitmap out to a file, and
attach it. Which is what I’ve done for v1 of this tool. The downside is
that you need to setup a directory that your ASP.NET application can
write to, and can clean up. This is a lot of work for very little gain.
Would’nt it be great if you could just create an attachment from a
stream?

Well, apparently there are a bunch of commercial SMTP
components which can do this, and while I’m not against them, I can’t
legitmize $200 per server for this little function – so I looked for
some open source stuff. I found some classes that send messages via
SMTP without using System.Web.Mail – they get all old skool and speak
SMTP and use TCP sockets. So this is the first part. They’re mostly C#
(and I’m a VB.NET kinda guy), but I may go ahead and extend them
to support adding attachments via streams. We’ll see if I need this,
but wanted to write it up anyhow…

Resources:
ComponentSpot is a great place for FREE components. Here are two SMTP projects
 
VB.NET Sending SMTP using Sockets

C# SMTP Mail without using SMTP Service or CDO (which is behind System.web.Mail)

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s