Outlook Redemption:如何将byte []数组添加为附件

时间:2017-11-20 14:57:45

标签: outlook-redemption

我接收文件为字节数组,需要通过Outlook / Redemption将这些文件作为附件发送。

safeMail.Attachments.Add(data, OlAttachmentType.olByValue, DisplayName:attachment.FileName);

导致错误:

{"Could not convert variant of type (OleStr) into type (Double)"}

我假设因为Add()方法需要变量数组?如何将字节数组转换为Add()方法将接受的内容?

1 个答案:

答案 0 :(得分:0)

使用SafeMailItem对象可能不是最佳选择,因为您仍需要设置附件文件名。 RDO系列对象将是一个更好的选择。

有些事情:

  dim data(3)
  data(0) = "t"
  data(1) = "e"
  data(2) = "s"
  data(3) = "t"
  set Session = CreateObject("Redemption.RDOSession")
  Session.MAPIOBJECT = Application.Session.MAPIOBJECT
  set Msg = Session.GetDefaultFolder(olFolderDrafts).Items.Add
  Msg.Subject = "attach as array"
  set attach = Msg.Attachments.Add(data)
  attach.FileName = "test.txt"
  attach.DisplayName = "test.txt"
  Msg.Save