Excellent, any clue how to add an attachment???
----- Felipe T. wrote: -----
Yeah...Other Suggestion;
I found this class somewhere, and i kept it for future uses. It works very
well using sockets and SMTP. Mayb it can help ya.
'=======================================================
Imports System.IO
Imports System.Net.Sockets
Imports System.Text
Public Class SocketMail
Private _subject As String
Private _to As String
Private _server As String
Private _port As Integer = 25
Private _body As String
Private _date As Date = Now
Private _from As String
Private _cc As String
Private _bcc As String
Private ns As NetworkStream
Private client As New TcpClient
Public Sub New()
End Sub
Public Sub New(ByVal server As String, ByVal port As Integer)
_server = server
_port = port
End Sub
Public Sub New(ByVal server As String, ByVal port As Integer, _
ByVal from As String, ByVal [to] As String, _
ByVal subject As String, ByVal message As String)
_server = server
_port = port
_from = from
_to = [to]
_subject = subject
_body = message
End Sub
Public Property SMTPServer() As String
Get
Return _server
End Get
Set(ByVal Value As String)
_server = Value
End Set
End Property
Public Property [To]() As String
Get
Return _to
End Get
Set(ByVal Value As String)
_to = Value
End Set
End Property
Public Property From() As String
Get
Return _from
End Get
Set(ByVal Value As String)
_from = Value
End Set
End Property
Public Property CarbonCopy() As String
Get
Return _cc
End Get
Set(ByVal Value As String)
_cc = Value
End Set
End Property
Public Property BlindCarbonCopy() As String
Get
Return _bcc
End Get
Set(ByVal Value As String)
_bcc = Value
End Set
End Property
Public Property Port() As Integer
Get
Return _port
End Get
Set(ByVal Value As Integer)
_port = Value
End Set
End Property
Public Property Message() As String
Get
Return _body
End Get
Set(ByVal Value As String)
_body = Value
End Set
End Property
Public Property SendDate() As Date
Get
Return _date
End Get
Set(ByVal Value As Date)
_date = Value
End Set
End Property
Public Property Subject() As String
Get
Return _subject
End Get
Set(ByVal Value As String)
_subject = Value
End Set
End Property
Public Function Open()
client.Connect(_server, _port)
ns = client.GetStream()
Dim strMessage As String = "HELO TEST" & ControlChars.CrLf
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(strMessage)
ns.Write(sendBytes, 0, sendBytes.Length)
End Function
Public Function Close()
Try
Dim strMessage As String = "QUIT" & ControlChars.CrLf
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(strMessage)
ns.Write(sendBytes, 0, sendBytes.Length)
Catch
End Try
client.Close()
End Function
Public Function Send() As Boolean
Try
Dim response As Integer
Dim strMessage As String
strMessage = "MAIL FROM:" & _from & ControlChars.CrLf & _
"RCPT TO:" & _to & ControlChars.CrLf & _
"DATA" & ControlChars.CrLf & _
"date:" & _date.ToString & ControlChars.CrLf & _
"from:" & _from & ControlChars.CrLf & _
"to:" & _to & ControlChars.CrLf & _
"cc:" & _cc & ControlChars.CrLf & _
"bcc:" & _bcc & ControlChars.CrLf & _
"subject:" & _subject & ControlChars.CrLf & _
_body & ControlChars.CrLf & _
"." & ControlChars.CrLf
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(strMessage)
ns.Write(sendBytes, 0, sendBytes.Length)
Finally
client.Close()
End Try
Return True
End Function
End Class
'=======================================================
'Use the class this way:
'Test making a Form and put in a button..
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim mMail As New SocketMail("123.125.251.21", 25)
With mMail
.To = "(e-mail address removed)"
.From = "(e-mail address removed)"
.Subject = "E-Mail Title"
.Message = "Hallo Word"
.Open()
.Send()
.Close()
End With
End Sub
'=======================================================
----- Original Message -----
From: "Aaron" <
[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
Sent: Friday, February 13, 2004 2:11 PM
Subject: Send Email in CF
I am looking for info on how to send email in the CF.
and it
didn't seem to allow that. (Uses outlook)