[RESOLVED] [2005] E-Mailing?
I'm trying to make an e-mailprogram and got this code:
VB Code:
'create the mail message
Dim mail As New System.Net.Mail.MailMessage()
'set the addresses
'set the content
mail.Subject = "This is an email"
mail.Body = "this is the body content of the email."
'send the message
Dim smtp As New System.Net.Mail.SmtpClient("127.0.0.1")
smtp.Send(mail)
But can he e-mail from 127.0.0.1 (wich is my computer -> localhost) and what is the strange error he gives for "SmtpException was unhandled" What does that mean?
Cheers,
Thomas
Re: [RESOLVED] [2005] E-Mailing?
I'm now trying to mail an attachment, but the attatchment I've got is "System.Windows.Forms.OpenFileDialog_ Title_ FileName_"
VB Code:
Public Class Form1
Dim Stoppen
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'create the mail message
Dim mail As New System.Net.Mail.MailMessage()
Dim Van, Naar, Onderwerp, Tekst, Slaap, Host, Cc, Bijlage_1
Van = TextBox1.Text
Naar = TextBox2.Text
Onderwerp = TextBox3.Text
Tekst = TextBox4.Text
Slaap = TextBox6.Text
Host = TextBox7.Text
Cc = TextBox8.Text
Dim Bijlage As String
Bijlage = OpenFileDialog1.ToString
OpenFileDialog1.ShowDialog()
OpenFileDialog1.ToString()
Bijlage_1 = System.Net.Mail.Attachment.CreateAttachmentFromString(Bijlage, Bijlage)
'set the addresses
mail.From = New System.Net.Mail.MailAddress(Van)
mail.To.Add(Naar)
mail.CC.Add(Cc)
'set the content
mail.Subject = Onderwerp
mail.Body = Tekst
mail.Attachments.Add(Bijlage_1)
'send the message
Dim smtp As New System.Net.Mail.SmtpClient(Host)
'//CURSOR
Me.Cursor = Cursors.WaitCursor
smtp.Send(mail)
Me.Cursor = Cursors.Default
pBar1.Visible = False
MsgBox("Operatie geslaagd!")
End Sub
End Class
(It should be HOI.txt from C:\)