April 20, 2004, version 1.0
Agilent VEE Pro 7.0 example (not compatible with earlier revisions)
Instruments: Not applicable
OS Requirements: Microsoft Windows 98, NT 4.0, ME, 2000, or XP

To use this example, put the file email_with_attachments.vee anywhere handy and either double-click it or start VEE Pro 7.0 (or later) and Open it from the File menu.


Before you run it:

- Set the text constants To, From, Subject, and Message Text to what you wish. I suggest mailing to yourself for the first tests. Note that From needs to be in the right domain (e.g. somebody@agilent.com for a server in the Agilent domain), because SMTP (Simple Mail Transfer Protocol) servers will often reject mail sent from outside the domain. The From and To usernames need not exist, though you might get an emailed error message from the mail system after a short time if To doesn't exist.

- You can modify the list of attachments in the Attachment Filenames text constant. For testing, I've selected small attachments that most VEE Pro 7.0 users will find on their hard drive if they installed VEE in the default location.

- Finally, you'll need to locate an SMTP server that you can use to send the message. This is _not_ an Exchange server as typically used by Microsoft Outlook. If you don't already know of a suitable SMTP server, you should ask your system administrator. If you don't have a system administrator, your ISP should be able to tell you.


Now you can press the Run button, which will send the email, including the attachments.


This example differs from the Send Mail example in the System menu and the SendMail.vee example in the examples\DotNET\ directory in that it demonstrates how to add attachments to an email. 


Because of this, it uses a different "signature" for the System.Web.Mail.SmtpMail.Send() method. The other examples use a signature that accepts 4 Text parameters: to, from , subject, and body (the message text). It doesn't require a System.Web.Mail.MailMessage object, discussed below, but that limits its flexibility and usefulness.


This example uses a signature for the Send() method that accepts a System.Web.Mail.MailMessage, to which we can add System.Web.Mail.MailAttachment objects. So we require some extra steps to build and initialize the MailMessage, and to build and add to it the System.Web.Mail.MailAttachment objects.


Error-handling in the example is non-existent for simplicity. This is not recommended practice.


Microsoft is a U.S. registered trademark of Microsoft 

 Copyright 2004 Agilent Technologies, Inc.
