我正在尝试对文本进行流式处理,并获取可分配给发件人和收件人的值,以便使用SMTPClient发送邮件
|message sender recipient Stream peek|
message:= 'To: myemail@gmail.com, otheremail@yahoo.com
From: me@hotmail.com , ab@yahoo.com
Subject: mail test
Simple mail from me.'.
Stream:= message readStream.
peek:= Stream next.
peek = $T ifTrue[Stream position 2.
peek:= Stream next.
peek = $: ifTrue["How can get everything For To: and From:
as Senders and recipients"]].
我的另一个问题是
SMTPClient
deliverMailFrom: sender
to: recipient
text: message
usingServer: 'mail.mydomain'.
" ifTrue[Transcript show:('mail sent successfully')]"
如何查看此邮件并查看邮件是否已成功发送
答案 0 :(得分:3)
请分开您的问题,以便我们能够正确回答。回答你的第一个问题:
| message sender recipient stream subject |
message:= 'To: myemail@gmail.com, otheremail@yahoo.com
From: me@hotmail.com , ab@yahoo.com
Subject: mail test
Simple mail from me.'.
stream := message readStream.
[stream atEnd] whileFalse: [
line := stream nextLine trimBoth.
(line beginsWith: 'To:') ifTrue: [recipient := line allButFirst: 'To: ' size].
(line beginsWith: 'From:') ifTrue: [sender := line allButFirst: 'From: ' size].
(line beginsWith: 'Subject:') ifTrue: [subject := line allButFirst: 'Subject: ' size]].
我想你应该看一下PharoByExample的书。您可以在官方网站上免费下载:http://pharobyexample.org/