VB.NET and Reading messages

Discussion for developers using MailEnable.
Post Reply
needy
Posts: 2
Joined: Thu Oct 09, 2003 1:46 pm

VB.NET and Reading messages

Post by needy »

Interesting problem (at least I think so)...

Running ME Pro on a W2K server.

I am writing a Windows Service to monitor a mailbox folder and watch for incoming emails with a specific attachment from our sales force. Have all the file watching done to trigger the event. But I am a total newbie to Mail Enable.

When a valid email comes in I want to use the MEWebMail COM object to save out the attachment, then open it up and pull its contents directly into a db (again, I have this portion already coded - pulling data from the attachment that is).

What I need help on is how to get to my attachment from the email message? Documentation on this kind of thing is a little thin so I wondered if anyone else has done this and can give me a few pointers - specifically on how to use the MEWebMail.MailMessage GetAttachments(), GetMessage() and GetMessageDetails() functions.

Thanks.
Paul Robinson

MailEnable
Site Admin
Posts: 4441
Joined: Tue Jun 25, 2002 3:03 am
Location: Melbourne, Victoria Australia

Post by MailEnable »

Paul.

The WebMail ASP files for are readable from the following directory:

C:\Program Files\Mail Enable\BIN\WebMail\base\default\lang\EN\Forms\MAI

Specifically the file GetAttachment.asp outlines the construct:

Code: Select all

 	MessageID = Request("MessageID")
 	gPostOffice = Session("POSTOFFICE")
 	gUserName = Session("AUTH_USERNAME")
 	gPassword = Session("AUTH_PASSWORD")
 	FileName = Request("FileName")
 	oAttachment.PostOffice = gPostOffice
 	oAttachment.Username = gUsername
 	oAttachment.MessageID = MessageID
 	oAttachment.RelativeFolderPath = RelativeFolderPath 	
 	oAttachment.AttachmentFileName = FileName
 	Response.AddHeader "Content-Disposition", "attachment;filename=""" & oAttachment.AttachmentFileName & """"
 	oAttachment.GetAttachment
	Set oAttachment = Nothing 
You must call this from a web page though since the GetAttachment method implements the ASP type lib and after mime/uu/base64 decoding the attachment uses Response.BinaryWrite to send the attachment as a binary stream to the client.

There is no current means of accessing the attachment data by any other means other than in textual form (by opening the MAI file directly).
Last edited by MailEnable on Fri Oct 10, 2003 3:57 am, edited 1 time in total.
Regards, Andrew

MartynK
Posts: 1376
Joined: Sat Dec 28, 2002 1:12 am
Location: Hong Kong

Post by MartynK »

Another way to do this is use the Microsoft routines. If you look at the MTAPE script you can see the basics how it is done. I have used this method from within VB.Net

MailEnable
Site Admin
Posts: 4441
Joined: Tue Jun 25, 2002 3:03 am
Location: Melbourne, Victoria Australia

Post by MailEnable »

Something that may interest/be relevant is the ability to poll for new messages (without needing to load the whole message list).

See as follows:

Set oMessages= CreateObject("MEWebMail.MailMessages")
oMessages.PostOffice = "MyPO"
oMessages.UserName = "MyMailbox"
NewMessageCount = oMessages.GetNewMessageCount()
set oMessages = nothing
Regards, Andrew

davemarks
Posts: 1
Joined: Mon Apr 18, 2011 4:25 pm

Re: VB.NET and Reading messages

Post by davemarks »

Is there still no way to be able to save an attachment from an image to a file on the server?

I'm looking at the classic ASP webmail sourecode trying to create a script in ASP to download emails from a given account and store them in a mysql database, along with the attachments saved into a directory on the server

I can download the emails fine, but struggling to get the attachments from teh email to a file on the server - downloading to the browser is easy using the getattachment code but this isn't what i want

thanks

Post Reply