我正在尝试从文件夹中复制Outlook电子邮件并将其复制到Excel文档中。我现在有它拉主题和发件人,但我有两个主要问题。一,我不能用日期属性拉日期。二,我不能只提取消息内容,因为它从outlook消息中提取所有HTML。这是我现在的完整代码...
tell application "Microsoft Excel"
set LinkRemoval to make new workbook
set theSheet to active sheet of LinkRemoval
set formula of range "D1" of theSheet to "Message"
set formula of range "C1" of theSheet to "Subject"
set formula of range "B1" of theSheet to "From"
set formula of range "A1" of theSheet to "Date"
end tell
tell application "Microsoft Outlook"
activate
set theRow to 2
set theMessages to messages of mail folder "Requests"
repeat with aMessage in theMessages
my SetFrom(sender of aMessage, theRow, theSheet)
my SetDate(date of aMessage, theRow, theSheet)
my SetSubject(subject of aMessage, theRow, theSheet)
my SetMessage(content of aMessage, theRow, theSheet)
set theRow to theRow + 1
end repeat
end tell
on SetDate(theDate, theRow, theSheet)
tell application "Microsoft Excel"
set theRange to "A" & theRow
set formula of range theRange of theSheet to theDate
end tell
end SetDate
on SetFrom(theSender, theRow, theSheet)
tell application "Microsoft Excel"
set theRange to "B" & theRow
set formula of range theRange of theSheet to name of theSender
end tell
end SetFrom
on SetSubject(theSubject, theRow, theSheet)
tell application "Microsoft Excel"
set theRange to "C" & theRow
set formula of range theRange of theSheet to theSubject
end tell
end SetSubject
on SetMessage(theMessage, theRow, theSheet)
tell application "Microsoft Excel"
set theRange to "D" & theRow
set formula of range theRange of theSheet to theMessage
end tell
end SetMessage
此外,当代码将消息内容粘贴到excel文件时,它不会粘贴所有文本,它只会粘贴250个字符...请参阅下面的图片。
答案 0 :(得分:1)
我尝试了一些东西,发现了以下内容:
使用值time received
和plain text content
代替date
和content
:
tell application "Microsoft Outlook"
activate
set theRow to 2
set theMessages to messages of mail folder "Requests"
repeat with aMessage in theMessages
my SetFrom(sender of aMessage, theRow, theSheet)
my SetDate(time received of aMessage, theRow, theSheet)
my SetSubject(subject of aMessage, theRow, theSheet)
my SetMessage(plain text content of aMessage, theRow, theSheet)
set theRow to theRow + 1
end repeat
end tell
关于另一个问题,我使用set value of cell to ...
代替set formula of range to ...
取得了成功:
on SetMessage(theMessage, theRow, theSheet)
tell application "Microsoft Excel"
set theRange to "D" & theRow
set value of cell theRange of theSheet to theMessage
end tell
end SetMessage
可见单元格的内容少于整个邮件内容,但您可以滚动查看整个(纯文本)内容。
玩得开心, 迈克尔/汉堡/德国