我正在使用MCAPI.Net包装器通过Mandril发送电子邮件 我发送带附件的电子邮件失败了:
Dim api = New MandrillApi(GetKey())
Dim recipients = New List(Of Mandrill.Messages.Recipient)()
recipients.Add(New Mandrill.Messages.Recipient("someemail@gmail.com", "somename"))
'Dim atch As New Mandrill.Messages.Attachment("text/plain", "testattach.txt", True, File.ReadAllBytes("C:\Users\nirav.vyas.GALAXY\Desktop\testattach.txt").ToString)
'Dim attachs = New Opt(Of MailChimp.Types.Mandrill.Messages.Attachment)(atch)
'Dim attachs1(0) As Opt(Of MailChimp.Types.Mandrill.Messages.Attachment())
'attachs1(0) = atch
Dim mesage = New Mandrill.Messages.Message()
mesage.To = recipients.ToArray()
mesage.FromEmail = "noreply@freemindtech.com"
mesage.FromName = "Nirav"
mesage.Subject = "Test Email"
mesage.Html = "<div>Test</div><br/><br/><div><a href='www.google.com'>Lets test the link of other website, click me.</a></div><div><p>Below is test to see if images works</p><br/><br/><img src='http://www.nemopdf.com/images/knowledge/upload-files.jpg' alt='myimage' /></div>"
'mesage.Attachments = attachs1
Dim result As MVList(Of Mandrill.Messages.SendResult)
result = api.Send(mesage)
如果你看到评论的代码,那就是我无法弄明白的地方 有人可以帮我修复那段代码吗?
答案 0 :(得分:0)
试试这个
Dim atch As Mandrill.Messages.Attachment() = {New Mandrill.Messages.Attachment("text/plain", "testattach.txt", True, Convert.ToBase64String(System.IO.File.ReadAllBytes("C:\\Users\\nirav.vyas.GALAXY\\Desktop\\testattach.txt")))}
Dim attachs As New Opt(Of MailChimp.Types.Mandrill.Messages.Attachment())(atch)