1

在 LotusScript 代理中,我使用 MIME 类在 MIME 中创建了一个多部分邮件。它工作正常,邮件发送正确。

只有一个大问题:名称中带有重音字符的文件无法正确传输。内容正确,但名称不正确。我已经尝试了 100 种方法,但要么不可能,要么我做错了。

这是(部分)我的代码:

Set Me.mc = Me.mr.createChildEntity()
Set Me.mh = Me.mc.CreateHeader("Content-Disposition")
Call Me.mh.SetHeaderVal(disposition + {; filename="} & attName & {";charset="iso-8859-1"} )
Set Me.mh = Me.mc.CreateHeader("Content-ID")
Call Me.mh.SetHeaderVal( |<| & attName & |>| )
Set stream = Me.session.CreateStream
If stream.Open(attFile) Then
    Call Me.mc.SetContentFromBytes(stream, strContentType & {; charset="iso-8859-1"; name="} & attName & {"}, ENC_IDENTITY_BINARY)
    Call stream.Close
End If

如果我在 Notes 中手动创建邮件并发送相同的文件,它可以工作,但文件名是编码的。这个怎么拔??

更新: 我添加了以下函数来编码 attName:

Function URLEncode(s As String, cset As String) As String
    Dim v As Variant

    v= Evaluate(|@ReplaceSubstring(@URLEncode("| + cset + |";"| + s + |"); "%"; "=")|)
    URLEncode= "=?" + cset + "?Q?" + v(0) + "?="
End Function  
4

3 回答 3

1

我找不到任何方法来编码参数。看起来你必须自己编码参数。

@URLEncode( encodingFormat ; token )

Should encode the string and then yo can add the =?ISO-8859-1?Q? and ?= to the string.

Or you can use encodeText from the javax.mail.internet package end wrap that in LS2J

于 2012-05-02T11:09:07.353 回答
1

I've never embedded files, just images, but it sounds like using @URLEncode may be worth trying.

Dim attNameEncoded As String
attNameEncoded = Evaluate({@URLEncode("iso-8859-1"; "} + attName + {")})(0)
Call Me.mc.SetContentFromBytes(stream, strContentType & {; charset="iso-8859-1"; name="} & attNameEncoded & {"}, ENC_IDENTITY_BINARY)
于 2012-05-02T14:55:46.990 回答
0

You have to encode the file name as described here:

The filename may be encoded as defined by RFC 2231.

于 2012-05-02T13:50:49.427 回答