Solved

How to send Itself in an Email to an address that a person types in?

Posted on 2004-10-09
6
219 Views
Last Modified: 2010-05-18
Im making a Game in Visual Basic and im putting an "email to friend" option in a menu and I want it so when they click on "send to friend' it will ask for an email address and then type an address in and click ok and it will send itself to that person.  What would be the code for this?  Thanks
0
Comment
Question by:jrolson
  • 3
  • 2
6 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 12267888
The code for this depends on what you plan to use to send the email with.  Will it be Outlook, SMTP, or what?
0
 

Author Comment

by:jrolson
ID: 12267898
It will be Outlook I guess.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 12267933
Ok.  I'll provide a code sample showing how to send a message from Outlook.  However, Microsoft has implemented a security feature in Outlook that will pop a dialog box up each time you send a message.  It's a guard against a virus sending emails without your knowledge.  Some folks find it extremely annoying.  There's no easy way around it without using a third-party tool.  With that in mind, are you sure you want to use Outlook?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 76

Accepted Solution

by:
David Lee earned 125 total points
ID: 12267968
Here's the code for sending via Outlook.  All you'll need to do is specify the profile name in place of "ProfileName" and fill in the other values.

Private Sub SendMessage()
    'Include a reference to Microsoft Outlook x.x Object Library
    'Where x.x is your version of Outlook
    Dim objApp As New Outlook.Application, _
        objNS As Outlook.NameSpace, _
        objMessage As Outlook.MailItem
    Set objNS = objApp.GetNamespace("MAPI")
    objNS.Logon "ProfileName"
    Set objMessage = objApp.CreateItem(olMailItem)
    objMessage.To = "Recipient's Address"
    objMessage.Subject = "Subject"
    objMessage.BodyFormat = olFormatHTML 'Assuming you want to use HTML format
                                         'for the message body
    objMessage.Body = "Message"
    objMessage.Send
    Set objMessage = Nothing
    objNS.Logoff
    Set objNS = Nothing
    Set objApp = Nothing
End Sub
0
 

Author Comment

by:jrolson
ID: 12268525
Thanks
0
 
LVL 12

Expert Comment

by:BobLamberson
ID: 12268998
Hi jrolson,
You might want to look at the clickyes freeware to help with the popup dialog David mentioned.
http://www.contextmagic.com/express-clickyes/

Bob
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

730 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