#1
Posted 15 January 2013 - 12:42 AM
is there an easy way to send an email through c#? like your email in one textbox, my email in anouther textbox and the email itself in anouther textbox?
thanks.
Programmer(in training), hacker(in minimal training), good with computers and mature, all you need to know about me but feel free to talk to me, contact me or whatever, i am no danger.
#2
Posted 15 January 2013 - 12:44 AM
#3
Posted 15 January 2013 - 12:46 AM
No idea, sorry. However, I don't know your timezone, but if you are in the same as mine, it's 1 43 or so right now, so try waiting till most people are awake xD
my timezone is (UTC+10:00) conberra, melbourne, sydney. its 5:46pm now.
but thanx.
Programmer(in training), hacker(in minimal training), good with computers and mature, all you need to know about me but feel free to talk to me, contact me or whatever, i am no danger.
#4
Posted 15 January 2013 - 02:12 AM
#5
Posted 15 January 2013 - 06:49 AM
#6
Posted 15 January 2013 - 06:59 AM
is there an easy way to use a email server in C#, cause i tried to google it but i couldnt find anything that makes sense?I'm not familiar with the inner workings of C#, but my guess is that you'd need to interact with a mail server somehow. Probably something like hMailServer.
Programmer(in training), hacker(in minimal training), good with computers and mature, all you need to know about me but feel free to talk to me, contact me or whatever, i am no danger.
#7 Guest_ElatedOwl_*
Posted 15 January 2013 - 08:19 AM
#8 Guest_ElatedOwl_*
Posted 15 January 2013 - 08:36 AM
This requires two using statements at the top, System.Net and System.Net.Mail
MailAddress from = new MailAddress("youremailhere@gmail.com", "A display name here"); MailAddress to = new MailAddress("the receivers email here", "a display name here"); SmtpClient smtp = new SmtpClient() { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(from.Address, "your gmail password here") }; using (MailMessage mess = new MailMessage(from, to) { Subject = "Subject field of email here", Body = "The body for the email here" }) { smtp.Send(mess); }
First we need to set up two MailAddress objects - one for the sender and one for the receiver. The constructor takes the e-mail address and a display name (both as strings).
Next we need to set up an SmtpClient specific to google's server. Right after the new declaration we're using {} to initialize some values on the object, the only thing you need to change in this part is the NetworkCredential object - you need to specify the password to your g-mail account.
Next, we're use a using statement wrapped around the creation of a MailMessage. Again, we use an initializer to set the Subject and Body of the MailMessage. Inside of the using block we simply send the message. Voila.
#9
Posted 15 January 2013 - 08:45 AM
this example is for g-mail, but you can change the host and port to whatever. (and turn off ssl if the host doesn't support it)
This requires two using statements at the top, System.Net and System.Net.MailMailAddress from = new MailAddress("youremailhere@gmail.com", "A display name here"); MailAddress to = new MailAddress("the receivers email here", "a display name here"); SmtpClient smtp = new SmtpClient() { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(from.Address, "your gmail password here") }; using (MailMessage mess = new MailMessage(from, to) { Subject = "Subject field of email here", Body = "The body for the email here" }) { smtp.Send(mess); }
First we need to set up two MailAddress objects - one for the sender and one for the receiver. The constructor takes the e-mail address and a display name (both as strings).
Next we need to set up an SmtpClient specific to google's server. Right after the new declaration we're using {} to initialize some values on the object, the only thing you need to change in this part is the NetworkCredential object - you need to specify the password to your g-mail account.
Next, we're use a using statement wrapped around the creation of a MailMessage. Again, we use an initializer to set the Subject and Body of the MailMessage. Inside of the using block we simply send the message. Voila.
thanks, but im having a few problems. im not trying to sound stupid but where do you insert the code, how i understood it goes in a button but then i got an error? the error says:
"Error 1 The type or namespace name 'MailAddress' could not be found (are you missing a using directive or an assembly reference?) D:\C#\Email\Email\Email\Form1.cs 21 13 Email"
Programmer(in training), hacker(in minimal training), good with computers and mature, all you need to know about me but feel free to talk to me, contact me or whatever, i am no danger.
#10 Guest_ElatedOwl_*
Posted 15 January 2013 - 08:47 AM
#11
Posted 15 January 2013 - 08:50 AM
No offense but if what I said doesn't make sense you might want to pick up a book on C# or step through some simple tutorials. :x
most of it makes sense but am i doing something wrong?
Programmer(in training), hacker(in minimal training), good with computers and mature, all you need to know about me but feel free to talk to me, contact me or whatever, i am no danger.
#12 Guest_ElatedOwl_*
Posted 15 January 2013 - 08:52 AM
using System;Somewhere up there you need to add
using System.Net; using System.Net.Mail;
#13
Posted 15 January 2013 - 09:07 AM
The error means you didn't put the using statements up top. At the top of your code there should be a few lines that read like
using System;Somewhere up there you need to addusing System.Net; using System.Net.Mail;
Thank you so much, its working.
(but for some reason its not sending a email to hotmail only gmail?)
Programmer(in training), hacker(in minimal training), good with computers and mature, all you need to know about me but feel free to talk to me, contact me or whatever, i am no danger.
#14 Guest_ElatedOwl_*
Posted 15 January 2013 - 09:09 AM
#15
Posted 15 January 2013 - 09:23 AM
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
namespace Email
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MailAddress from = new MailAddress("henkros@hotmail.com", "Display");
MailAddress to = new MailAddress("dhr7777777@hotmail.com", "Desplay");
SmtpClient smtp = new SmtpClient()
{
Host = "smtp.live.com",
Port = 995,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(from.Address, "Password")
};
using (MailMessage mess = new MailMessage(from, to)
{
Subject = "New Test C#",
Body = "Hello World"
})
{
smtp.Send(mess);
}
}
}
}
whats wrong with it?
Programmer(in training), hacker(in minimal training), good with computers and mature, all you need to know about me but feel free to talk to me, contact me or whatever, i am no danger.
#16
Posted 15 January 2013 - 09:42 AM
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 System.Net;
using System.Net.Mail;
namespace Email
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MailAddress from = new MailAddress("henkros@hotmail.com", "Display");
MailAddress to = new MailAddress("dhr7777777@hotmail.com", "Desplay");
SmtpClient smtp = new SmtpClient()
{
Host = "smtp.live.com",
Port = 995,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(from.Address, "Password")
};
using (MailMessage mess = new MailMessage(from, to)
{
Subject = "New Test C#",
Body = "Hello World"
})
{
smtp.Send(mess);
}
}
}
}
whats wrong with it?
nevermind, i got it.
thank you so much
Programmer(in training), hacker(in minimal training), good with computers and mature, all you need to know about me but feel free to talk to me, contact me or whatever, i am no danger.
Also tagged with one or more of these keywords: Software, programming
Computers →
Coding →
Learning Data Science with Python ProgrammingStarted by AI Patasala, 22 Dec 2021 Data Science, Python, Code and 2 more... |
|
||
Nerd Forum Information →
Introductions →
Hey, I'm a newbie hereStarted by codegeek, 02 Aug 2020 coding, programming, tech and 2 more... |
|
||
Nerd Forum Information →
Introductions →
New Member IntroductionStarted by sunnychawla, 02 Apr 2018 introduction, programming and 5 more... |
|
||
Nerd Forum Information →
Help and Error Reporting →
Programming old aviation radios with DOS software thru LPT1 portStarted by snowtar, 28 Oct 2016 DOS, LPT1, parallel, old and 4 more... |
|
||
Computers →
Coding →
ModdingStarted by gigatime, 17 Aug 2014 mods, modding, games, coding and 4 more... |
|