0

メールに添付ファイルを送信しようとしていますが、うまくいかないようです。添付ファイル セクションを使用しない場合は、メールを送信できます

これらのインポートを使用しています

Imports System.IO
Imports System
Imports System.Web.Mail

Dim mail As New MailMessage()
mail.To = strTo
mail.From = strFrom 
mail.Subject = strSubject
mail.BodyFormat = MailFormat.Html
mail.Body = sBody
'mail.Attachment.Add (strAttachment)
'mail.AddAttachment(strAttachment)


'mail.Attachments.Add(New MailAttachment(strAttachment))
 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "xxxxxxxxxxxx") 'set your username here
 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xxxxxxxxxxx") 'set your password here
 SmtpMail.SmtpServer = "xxxxxxxxxxxx" 'your real server goes here
 SmtpMail.Send(mail)
4

1 に答える 1

3

これを試して

Dim m as new MailMessage
m.Attachments.Add(New Attachment("C:\Test.txt"))
'rest of your code
于 2012-08-31T16:01:38.150 に答える