如何使用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

我想在默认客户端加载之前在其中添加一个附件。不幸的是,我在网上找不到任何答案。你能给点建议吗?

您需要调用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)

请参考。

希望有所帮助

相关内容

  • 没有找到相关文章

最新更新