找到“回车"在mail.body中 [英] Find "carriage return" in a mail.body

查看:63
本文介绍了找到“回车"在mail.body中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的邮件:

你好

请注意,我们是在16点15分完成的

Please note we did ... at 16h15

已完成的操作:重建等

真诚地

先生

每个邮件中的操作都会更改,我想要在Excel中插入操作.问题是我不知道如何获得回车费"(idk,如果这是正确的名称,这就是交易给我的意思). 我在互联网上发现的是vbLfChr(10)是回车符". 我试图找到起点:

The actions change in every mail and what I want is to insert the action in my Excel. The problem is that I don't know how to get the "carriage return" (idk if this is the right name, this is what traduction gave me). What I find in internet is that vbLfChr(10) is the "carriage return". What I tried is to find the beginning :

TechnicPosition= InStr(1, .Body, "Actions done: ")
TechnicAction= Mid(.Body, TechnicPosition, 14) ' first char from the action

但是我无法获取最后一个字符(来自TechnicAction的第一个回车"). 我尝试了很多类似的东西:InStr(TechnicPosition, .Body, vbCrLf)

But I can't get the last char (first "carriage return" from TechnicAction). I tried many things like : InStr(TechnicPosition, .Body, vbCrLf)

我的问题:如何获得一个从单词开始到回车"的句子(第一个单词后面的单词)?

My question : how to get a sentence that begin from a word to a "carriage return" (the first that comes after the beginning word) ?

推荐答案

电子邮件正文中的carriage return通常是vbNewline

The carriage return in the email body is usually vbNewline

这是我通常的做法

Sub Sample()
    Dim sBody As String
    Dim MyAr
    Dim i As Long

    '
    '~~> Rest of your code
    '

    sBody = oMail.Body

    '~~> For testing purpose
    'sBody = "Hello," & vbNewLine & vbNewLine
    'sBody = sBody & "Please note we did ... at 16h15" & vbNewLine & vbNewLine
    'sBody = sBody & "Actions done: Rebuilding etc" & vbNewLine & vbNewLine
    'sBody = sBody & "Sincerely"

    '~~> Split the email body on vbnewline and store it in array
    MyAr = Split(sBody, vbNewLine)

    '~~> Loop through array
    For i = LBound(MyAr) To UBound(MyAr)
        '~~> Check if the line has "Actions done:"
        If InStr(1, MyAr(i), "Actions done:") Then
            '~~> This would give you "Rebuilding etc"
            '~~> Split the line on "Actions done:"
            '~~> You will get an array. Ar(0) will have "Actions done:"
            '~~> And Ar(1) will have what you are looking for so we use
            '~~> Split()(1) directly to access that item
            MsgBox Split(MyAr(i), "Actions done:")(1)
            Exit For
        End If
    Next i
End Sub

修改

另一个方式

这篇关于找到“回车"在mail.body中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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