使用Word编辑器时,发送方法不起作用 [英] Send method not working when using Word Editor

查看:108
本文介绍了使用Word编辑器时,发送方法不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一条规则,就是每当我收到一封主题行中包含特定单词的电子邮件时,都会触发此脚本.

I have a rule that whenever I receive an email with a specific word in a subject line, it will trigger this script.

该脚本会将电子邮件转发给主题行中的特定用户,并使用文字编辑器删除电子邮件正文的第一行并将其更改为"Hi".

The script will forward the email to the specific user in the subject line and use the word editor to delete the first line of the email body and change it to "Hi,".

当我使用.Display方法然后手动单击send时,它工作正常,但是每当我使用.Send方法时,Outlook都不会更新/接收邮箱中的电子邮件,也不会转发已编辑的电子邮件电子邮件.我需要关闭/重新启动Outlook脚本才能再次触发.

When I use .Display method then manually click send it is working fine, but whenever I use .Send method, the outlook won't update/receive the email in the mailbox and won't forward the edited email. I need to close/relaunch outlook for the script to trigger again.

脚本有什么问题?

Sub EmailForward(item As Outlook.MailItem)

    Dim body As String
    Dim MI As MailItem
    Dim oMail As Outlook.MailItem

    Dim olInsp As Outlook.Inspector
    Dim wdDoc As Object
    Dim oRng As Object
    Dim objSel As Word.Selection

    Dim olApp As Outlook.Application

    Set MI = item
    Set olApp = Outlook.Application

        item.Subject = Replace(item.Subject, ", 4 - Low, Open", "")
        item.Subject = Replace(item.Subject, ", 4 - Low, New", "")
        item.Save

        Eadd = Right(MI.Subject, Len(MI.Subject) - InStr(MI.Subject, "|"))

        Set oMail = MI.Forward

        oMail.Subject = MI.Subject
        oMail.To = Eadd
        oMail.HTMLBody = item.HTMLBody

            Set olInsp = oMail.GetInspector
            Set wdDoc = olInsp.WordEditor
            Set oRng = wdDoc.Range(0, 0)
            Set objSel = wdDoc.Windows(1).Selection
            'oRng.Text = "The accompanying message text"

            objSel.MoveDown wdLine, 1, wdExtend
            objSel.Delete wdCharacter, 1
            objSel.TypeText Text:="Hi,"
            objSel.TypeParagraph

        oMail.SendUsingAccount = olApp.Session.Accounts.item(1)
        oMail.Display
        oMail.Save
        oMail.Send

End Sub

推荐答案

这是Outlook中的已知问题.您必须先调用Display方法才能使检查器可见.

That's a known issue in Outlook. You have to call the Display method first to get the inspector visible.

使用HTMLBody或Body属性即时修改邮件正文.

Use the HTMLBody or Body property to modify the message body on the fly.

这篇关于使用Word编辑器时,发送方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆