Groups | Blog | Home
all groups > vj# > february 2006 >

vj# : Sending email from J#


Homer J Simpson
2/2/2006 10:22:27 PM

Is there a good source of code for sending email from J# which isn't a
'deprecated' method? I find the documentation less than helpful.

H

Homer J Simpson
2/3/2006 3:20:12 AM

[quoted text, click to view]

To answer myself (after 16 tries):

import System.Net.Mail.*;

private void btnSend_Click(Object sender, System.EventArgs e)
{
MailAddress myTo = new MailAddress(toaddress);
MailAddress myFrom = new MailAddress(fromaddress);
MailMessage myMessage = new MailMessage(myFrom, myTo);
myMessage.set_Body("This is the body");
myMessage.set_Subject("This is the subject");
SmtpClient myClient = new SmtpClient("smtp.server.net");
myClient.Send(myMessage);
}

============================================================
toaddress and fromaddress should be email addresses in quotes (which OE
obligingly screws up).


Lars-Inge Tønnessen (VJ# MVP)
2/25/2006 3:20:31 AM
Incliude a reference to System.Web.
In the System.Web.Mail namespace you will find a simple SMTP function. If
you want more advanced functionality, there are lots of third part SMTP
libraries on the net. For POP3 please use a 3 part library.

Best Regards,
Lars-Inge

AddThis Social Bookmark Button