如何在 vb.net 中使用默认电子邮件客户端发送带附件的电子邮件
How to send an email with attachment using default email client in 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)
请参考this。
希望对您有所帮助
我想知道是否可以做到这一点。可以吗?
这是我的简单代码:
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)
请参考this。
希望对您有所帮助