Well, I've got this now:
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 myFile As String = OpenFileDialog1.FileName 'Assign selected filename to var If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then MessageBox.Show(myFile) 'It gives full path End If 'set the addresses mail.From = New System.Net.Mail.MailAddress(Van) mail.To.Add(Naar) If CheckBox1.Checked Then mail.CC.Add(Cc) End If 'set the content mail.Subject = Onderwerp mail.Body = Tekst mail.Attachments.Add(myFile) '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
But:Wich is here:Error 1 Value of type 'String' cannot be converted to 'System.Net.Mail.Attachment'. E:\Documents and Settings\The King\Mijn Documenten\Visual Studio 2005\Projects\Mail\Mail\Form1.vb 52 30 MailVB Code:
mail.Attachments.Add(myFile)
How can I solve that?




Reply With Quote