Solved

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

Posted on 2004-10-09
6
215 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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.
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…
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…

760 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

20 Experts available now in Live!

Get 1:1 Help Now