REBOL学习笔记 eml对象的生成

来源:互联网 发布:国云大数据 编辑:程序博客网 时间:2024/06/05 16:14
上一次讲了如何发送邮件,发的是一种标准的eml格式的文件,这一次自己编写了生成EML格式文件的对象,也可以不写文件而直接发送对象的TEXT也可以。
REBOL [Titile="emlobj"]
end:{
}
eml: make object! [
    From: "<发信人>"
    Date: now/time
    MIME-Version: "1.0"
To: "<收信人>"
Subject: "标题"
Content-Type: "multipart/mixed"
boundary: {"-------=emldate="}
Msg: {邮件内容}
File: ""
Name: ""
setn: func[] [
From: ask "发件人:"
To: ask "收件人:"
Subject: ask "主题:"
Msg: ask "内容:"
F: request-file
Name: to-file F
File: enbase read Name
]
    Text: func [] [
        Rejoin[
"From: " From end
"Date: " Date end
"MIME-Version: " MIME-Version end
"To: " To end
"Subject: " Subject end
"Content-Type: multipart/mixed;" end
{ boundary="-------=emldate="} end end
"This is a multi-part message in MIME format." end end
"---------=emldate=" end
{Content-Type: text/plain;
charset="gb2312"
Content-Transfer-Encoding: 7bit
}
Msg end
"---------=emldate=" end
{Content-Type: text/txt;
name="} Name {"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="} Name {"
} end
File end end
"---------=emldate=--" end
]
    ]
]
eml/setn
write %a.eml eml/Text 
原创粉丝点击