Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Gurus*
Posted

Connect via a Socket class, then you'll need to have the following conversation with the SMTP server (port 25):

 

< 220 Ready
> MAIL FROM:myemail@mydomain.com
< 250 Sender ok
> RCPT TO:recipient@domain.com
< 250 Recipient ok
> DATA
< 354 Ok Send data ending with <CRLF>.<CRLF>
> sample email line!
> .
< 250 Ok, sent
> QUIT
< 221

 

I suggest you read the SMTP RFC for more information on the protocol.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Many thanks for your answer, could you specify me more (or give any link) about the socket class connection, I'm really newbie to that. Thanks again.

 

In fact, what I seem in your code is that it's very like a TELNET sending of an email, but, what I really don't know is how to make that code to function automatized by VB application.

tHe pHrEaKy
  • *Gurus*
Posted

Yes, it's a TCP connection just like a telnet one. There are .NET classes under System.Web.Mail but you said you wanted to send one directly using an SMTP server so I assumed you wanted to do it manually.

 

There are examples of using the Socket class in the documentation and samples in the SDK.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Well, actually I think that manually is the best way, here it is what I need to do:

 

I need to send through an email just one string, but, I need to do it automatized way, what I will send and where I'm going to send it are constants, so, I don't need to enter them ("to" and "data") every time it will be sent. Now, you tell me, what's the best for me?, maybe I could use System.Web.Mail class, in fact, it sounds much more easier for what I need, but using this class I can set the target (TO) and the content (DATA) and send it without disturbing my user (of the application)?. :)

tHe pHrEaKy
Posted
As long as you have access to a SMTP server then System.Web.Mail will do all that you need.

 

Ok, I got my SMTP server, in fact, mi ISP gives me SMTP server completely free and with no restrictions, now, how do I do it? :(

tHe pHrEaKy
  • *Gurus*
Posted

Straight from the help:

 

Dim from As String = "from@microsoft.com"
Dim mailto As String = "to@microsoft.com"
Dim subject As String = "UtilMailMessage001"
Dim body As String = "<html><body>UtilMailMessage001 - success</body></html>"
SmtpMail.Send(from, mailto, subject, body)

 

string from = "from@microsoft.com";
string to = "to@microsoft.com";
string subject = "UtilMailMessage001";
string body = "<html><body>UtilMailMessage001 - success</body></html>";
SmtpMail.Send(from, to, subject, body);

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Well, the code that divil gave me didn't work, it doesn't recognizer SMTPMail.xxxxxx as a function or a class.

 

In the other side, there's a weird thing that's happening, I read what Derek gaves to me, about the class System.Web.Mail.SMTP that appears on the help, but IT DOESN'T RECOGNIZES this one either!, I mean, when a start typing System, the VB suggest diferent kinds of options of sub divisions of the class System (as usual), but there's no subdivision Web and of course none of the others sub of the sub, anyway, I installed it complete!, so, I really dunno why is that happening. Any clue?

tHe pHrEaKy
  • *Experts*
Posted

OK, first this you have to do is go to the 'Project' menu and click

'Add Reference'. Find 'System.Web.dll' in the list of references, and

double click it, then click OK. Then the code will work.

 

Dim m As System.Web.Mail.SmtpMail
Dim sFrom, sTo, sSubject, sMessage As String

sFrom = "email@mail.com"
sTo = "email@mail.com"
sSubject = "This is a test"
sMessage = "Blah blah blah"

m.Send(sFrom, sTo, sSubject, sMessage)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...