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 MailMessageEmail.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.WebClientDim OutputBitmap As Bitmap = New Bitmap(webC.OpenRead(http://myims/output/map2.gif))
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...
I'm Dave and this is my blog. I'm usually writing about .NET Software Development, ArcGIS, or Agile Practices, but other stuff does creep in from time to time. I hope you find something of use, and feel free to contact me if you have any questions. You can also check out my profile on LinkedIn
dojo.DTSAgile.com is our technology preview / demo site. As I and my team cook up cool things we post them here.
ArcDeveloper.net is a site that hosts a set of open source projects related to ArcGIS. This includes Tile Cache for .NET (TC4N) and Feature Server for .NET (FS4N). Come over and check it out!
Assembla is a free service that provides Subversion source control, wikis and work Tracking. The ArcDeveloper project is run from here. It rocks. Check them out today.
Agilistas is a LinkedIn group focused on discussing and promoting Agile practices. Everyone is welcome to join in the conversation as we evolve the process of creating software to make it more enjoyable for all involved.