Solved

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

Posted on 2004-10-09
6
220 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
[X]
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
  • 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:Bob Lamberson
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

Independent Software Vendors: 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!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

717 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