Solved

Sending an Email

Posted on 2000-04-26
6
173 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating VB6 Function 19 59
passing parameter in sql procedure 9 61
VBA Shell can't Find Word document 11 92
Help me. 3 54
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

785 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