Send mail med vedhæftet fil i vb 2008 ?
Jeg har skrevet følgene code det virker fint at sende en mail, men jeg kan ikke attache nogen fil er der en der kan hjælpe mig lidt ?Imports System.Net.Mail
Public Class SendMail
Public Sub SendEmail(ByVal pathandfilename As String)
'create the mail message
Dim mail As New MailMessage()
Dim File As String
'set the addresses
mail.From = New MailAddress("mail adresse")
mail.To.Add("mail adresse")
'set the content
mail.Subject = "Pris på Laserskæring"
mail.Body = "Pris på forspurgte emne incl. opstart" & vbCrLf & Form1.TextBox1.Text & vbCrLf & "Tak for henvendelsen"
mail.IsBodyHtml = True
'add an attachment from the filesystem
File = "C:\Documents and Settings\Skrivebord\Mail\10007_R - Sheet1.dxf"
' mail.Attachments.Add(New Attachment(File, ReceiveMail.AttachFile))
mail.Attachments.Add(New Attachment(File, ".dxf"))
'mail.Attachments.Add(New Attachment(AttachFile))
'send the message
Dim smtp As New SmtpClient("*******-smtp.****.com")
smtp.Credentials = New System.Net.NetworkCredential("USERNAME", "PASSWORD")
Try
smtp.Send(mail)
Finally
mail.Dispose()
smtp = Nothing
End Try
End Sub