Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sending an Email

Posted on 2000-04-26
6
Medium Priority
?
179 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 600 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

963 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