2016-09-27 156 views
0

我在想如何才能做到。可以做到嗎?如何使用vb.net中的默認電子郵件客戶端發送帶附件的電子郵件

這裏是我的簡單的代碼:

Try 
    MsgBox("Please wait this may takes time to load", vbInformation, "Mailing System") 
    System.Diagnostics.Process.Start("mailto:" & txtEmailadd.Text) 
Catch ex As Exception 
    MsgBox(ex.Message & " Having some technical difficulties, kindly check if the email textbox has data in it", vbCritical, "System Advisory") 
End Try 

我想要的默認客戶端負載之前增加的這裏面的附件。不幸的是,我在網上找不到任何答案。你能提出一些建議嗎?非常感謝提前。

回答

0

您需要調用MailMessage.Attachments()。以下是示例代碼:

Dim MailMsg as New MailMessage 
Dim loAttachment As Attachment = Nothing 
Dim ls_email_attach as String 
Dim server as String 

ls_email_attach = "attach.xls" 
server = "Mail server info" 

//add the attachment 
If Not ls_email_attach.Trim = "" Then 
     loAttachment = New Attachment(ls_email_attach) 
     loMailMsg.Attachments.Add(loAttachment) 
End If 

//send the email 
MailMsg = New SmtpClient(server) 
MailMsg.Send(loMailMsg) 

請參閱this以供參考。

希望它有幫助

+0

嗨,謝謝你的回覆。我會試試這件事。 –

相關問題