Solved

Sending an Email

Posted on 2000-04-26
6
170 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
Comment Utility
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 69

Expert Comment

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

Author Comment

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

Thanks.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Expert Comment

by:jgravelle
Comment Utility
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
Comment Utility
Adjusted points from 100 to 150
0
 

Author Comment

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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now