0

我正在使用 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)

如果您看到注释代码,那是我无法弄清楚的地方。
有人可以帮我修复那个代码吗?

4

1 回答 1

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)
于 2015-07-21T09:51:30.790 回答