Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-10-09
6
Medium Priority
?
222 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
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.

 
LVL 76

Accepted Solution

by:
David Lee earned 375 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Suggested Courses

636 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