Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Sending an Email

Posted on 2000-04-26
6
174 Views
Last Modified: 2010-05-02
I would like to add code to send an email when my code is finished executing.  Is there an easy way to do this?  A code example would be great!!!

Thanks.
0
Comment
Question by:mjcotter
  • 3
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
jgravelle earned 150 total points
ID: 2752546
If you are using Outlook as an Email program you can do the following:
First set a Reference to the Outlook 98 Type library(Project...References)

On your Form_Unload event:

Private Form_Unload

Dim appObj As New Outlook.Application
Dim itemObj As Object

On Error Resume Next

Set itemObj = appObj.CreateItem(olMailItem)

itemObj.To = "someemail@somewhere"

itemObj.Body = "This is the body of the
message"

itemObj.Subject = "This is the Subject"

itemObj.Send

Set itemObj = Nothing
Set appObj = Nothing

End Sub

Hopes this helps!!!
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2752600
Use the EE search option and look for SMTP. You will have plenty of examples.
0
 

Author Comment

by:mjcotter
ID: 2752740
I assume I could also attach a file to the mail message.  Do you know what the command would be?

Thanks.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:jgravelle
ID: 2752758
Yes you can attach a file to the email message: Add the following to the previous code:

Dim attObj As Outlook.Attachment

Set attObj = itemObj.Attachments.Add(attName)

**Where attName is the full path of the file you are attaching.**

If you have any trouble let me know.

0
 

Author Comment

by:mjcotter
ID: 2754965
Adjusted points from 100 to 150
0
 

Author Comment

by:mjcotter
ID: 2754966
Thanks a lot!  You have been very helpful.  Everything has worked like a charm.  Thanks again!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question