You are here:

ActiveXperts.com > Email Component > Mime and Email Component
ActiveXperts Email Component

Quicklinks

Using MIME (.mim) files in a Windows Development/Scripting environment using Email Component

MIME stands for Multipurpose Internet Mail Extensions. A MIME file is a binary file that has been encoded into a text file for the purpose of transmitting it over the Internet email system. Internet email can handle text files only. So when a binary file is attached to an email message, that binary file is converted to text before being sent from the sender's computer. This process is known as "encoding", and usually occurs in the background where the sender does not see it, is not aware of it and does not even know the process exists. When the email with the attached file is received by the intended recipient, the attached/encoded text file is converted back to its original binary form by the recipient's email program. This process of converting the file from text back to its original binary form is called "decoding." This process usually occurs in the background as the mail message and attachment are being retrieved by the recipient. The recipient generally is not aware of this decoding process, and doesn't really care so long as the received attached file is what is expected.

Email Component supports import/export of MIME files. You can for instance use Outlook Express to export an e-mail message to a MIME files, and import this message in Email Component using the SmtpMail::LoadMIME function. After that, you can send the imported message via the SMTP server to a remote recipient.

Sample: Load a MIME message and use an SMTP server to send the message 
Set objSmtpServer       = CreateObject("AxEmail.Smtp") ' Create SMTP server object
Set objSmtpMail         = CreateObject("AxEmail.Message")   ' Create mail object

  objSmtpServer.Connect( "smtp.mydomain.com" )  
  Wscript.Echo "Connect, result: " & objSmtpServer.LastError

' Load mail properties
  objSmtpMail.LoadMIME( "c:\mye-mail.mim" )                         ' Load prop's, recip's & attachments 

  objSmtpServer.Send( objSmtpMail )                                 ' Send now 
  WScript.Echo "Send, result: " & objSmtpServer.LastError
  WScript.Echo "Last response: " & objSmtpServer.LastSmtpResponse 
End If  

objSmtpServer.Disconnect                                            ' Finally, disconnect
Sample: Retrieve all messages from a POP3 mailbox and store each as a MIME file

Set objPop3Server       = CreateObject("AxEmail.Pop3") ' Create Pop3Server object

objPop3Server.Connect( "pop3.mydomain.com", "userid", "passwd" )  ' Connect to POP3 server and login
Wscript.Echo "Connect, result: " & objPop3Server.LastError

numMessages = objPop3Server.CountMessages()                       ' Count the messages in the mailbox
WScript.Echo numMessages & " new message(s) in mailbox."
For i = 1 to numMessages                                          ' Iterate over all messages
     Set objPop3Mail = objPop3Server.GetEmail( i )                ' Get e-mail
     objPop3Mail.SaveMIME( "C:\Mail" & i & ".mim"                 ' Save mail as C:\MAILx.MIM
Next
objPop3Server.Disconnect                                          ' Disconnec