Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Receive Email, Save 1

Status
Not open for further replies.

DSTR3

Technical User
Jan 21, 2005
41
US
I'm new to VB6. I need a simple solution to receiving an EMail and saving the attachment to a specfic directory. It has to be a stand alone application that I can bring up from Access. Something simple. Just a Download button and a Cancel button. Any help appreciated.
Thank You
DSTR3
 
This may not be quite as easy as you'd like.

A mail client (mail user agent: MUA) cannot receive email message as such. It is more of a presentation tool or user interface to your mailbox which normally resides within a mail server (mail delivery agent or MDA in combination with a mail transfer agent or MTA).

This means you'll need a "mail server" (typically an MDA paired with an MTA, or perhaps a combined MD/TA). The mail server is what receives email.

An MUA can "pull" email, but only from the stored messages in your mailbox. Since most Windows client systems don't run a mail server, remote retrieval protocols such as POP3 or IMAP4 are used to pull messages from the mail server's drop directory or mailstore.


It sounds as if you want a simple POP3 client.


However this client needs to have some way to distinguish among the received email messages stored at the mail server. There could be multiples of these, including spam or other unsolicited email messages.

It would be possible to create a custom POP3 client that browses the mailbox for messages and only pulls those of interest based upon the message length or size. Message number and length are the only two things a POP3 server normally returns on a POP3 "LIST" command from the client. Some servers could also return the sender and even the subject parsed from each mail message in this scan list, but they are not required to.

You could also just "drain" the mailbox and pull down all messages it contains. Then you can examine lots of other attributes like the sender, body text, attachments, etc. Those that are unexpected can be logged or simply discarded.

Even so, what if you find two or more messages in the mailbox that meet your criteria? What then? Process all of them? Use the first and discard the rest?


As far as the mechanics of creating a custom POP3 client in VB5 or 6 goes, you basically have three paths:
[ul][li]A MAPI client that piggybacks on a full mail client like Outlook or Outlook Express.[/li]
[li]A stand-alone POP3 client based on some 3rd party POP3 component flexible for your needs.[/li]
[li]A fully rolled-on-your-own POP3 client based on the Winsock control or Winsock API.[/li][/ul]

If you want IMAP4 access to your server the details vary but the overall plan of attack and component tool options are much the same.


More details on all of these approaches can be found by searching this forum. This may be a bit much to bite off for somebody "new to VB" though.

Perhaps you'd want to either hire a programmer or else search the Web for ready-made clients like the one you seek.
 
Thank you for your answer. You right, this is a lot. I thought that it would be simple. Basically, I'm getting E-Mails from one to ... number of pre-defined sources only, most likely 10 at the most. I just need to grab a text file(s) and save it or them to a directory. I could just click and save the attachment in Outlook, but I was hoping to avoid having the user saving the file from Outlook. Any other suggestions would be appreciated and once again thank you for your very informative answer!
DSTR3
 
Can you use ftp to save the files to a folder? I assume there are 10 users sending files as attachments in email, instead of doing that they would use ftp to save the files to your ftp server.
 
I'm trying to avoid using ftp. I don't want to incur another monthly charge. I figured out how to receive the mail. And save it, now saving the attachment is the problem. See my other post "Saving Attachments"
Thanks
DS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top