编辑:在帖子底部添加了更接近我试图操作的实际字符串的片段。这不是逐字删除的关键信息,而是我从我要转发的电子邮件中复制和粘贴的。只是试图在中间和前面提取表格。
我想删除我收到的电子邮件中的特定文本,删除超链接,保留格式,然后转发到特定地址。
基本上,电子邮件的结构如下:
“亲爱的用户,
请在下面找到相关信息
数据库:记录点击这里在线查看
- 表头
- 列标题
- 记录 1
- 记录 2
- 记录 3
- ...
- 最终记录
如果您在使用上面的链接时遇到问题,请将此链接粘贴到您的地址栏中以访问在线数据库:
somewebsite.database.net/tr/vuioahdf
这是一封自动发送的电子邮件……”
我需要删除表格前的文字,删除超链接,保留格式,然后转发。
我尝试了以下。
Sub RemoveExpression()
Dim Insp As Inspector
Dim obj As Object
Set Insp = Application.ActiveInspector
Set obj = Insp.CurrentItem
obj.Body = Replace(obj.Body, "Dear user, please find the relevant information below database: records click here to view this online - Table header " & _
vbNewLine & "If you have trouble using the link above, paste this link in your address bar to go to the online database http://somewhere.database.net/tr/vuioahdf This is an automated email...", "")
Set obj = Nothing
Set Insp = Nothing
End Sub
它给了我一个关于未定义对象的错误,但这与我想要做的事情一致。删除表格前后的一些文字,删除超链接,然后转发到特定地址。删除超链接可能不是完全必要的,因为它主要位于表格前后的文本中,但表格标题中有一个超链接。
我试图操纵的电子邮件:
Dear User,<br>
<br>
Please find below drawing received last week for project
<br> <br>
<b><u></u>Document Control: Projects<u></u></b><br>
Click <a href="somehwere.net" target="_blank">here</a> to see this report on the database.
<br> <br>
<div style="font-size:70%;font-family:Verdana,Helvetica,Geneva,sans-serif">
<div>
<table width="100%" cellpadding="0" cellspacing="0">
<tr style="background-color:#c4defb">
<td style="border-top:1px solid #55a0ef;border-bottom:1px solid #55a0ef">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td style="width:200px;padding:4px 8px;font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;color:#505050;font-weight:normal;font-size:9pt">
<a style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;color:#505050;font-weight:normal;font-size:9pt;text-decoration:none" href="somewhere.net" title="See this report" target="_blank">Full Report</a>
| <a style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;color:#505050;font-weight:normal;font-size:9pt;text-decoration:none" href="somewhere.net" title="Edit all the Drawings shown below" target="_blank">Grid Edit</a>
</td>
<td style="width:200px;padding:4px 8px;font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;color:#505050;font-weight:normal;font-size:9pt" align="right">
<span><label>Date Created</label> is during <label> 'last 2 wk' </label> AND ...</span> <span>11 Drawings</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" cellspacing="0" cellpadding="0">
<thead style="display:table-header-group">
<tr>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;background-color:#f6f9fd;padding:3px 4px;font-weight:bold;font-size:10pt;color:#111111"> </td>
<td align="right" style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;background-color:#f6f9fd;padding:3px 4px;font-weight:bold;font-size:10pt;color:#111111"><div></div><span>Date Created</span><span></span></td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;background-color:#f6f9fd;padding:3px 4px;font-weight:bold;font-size:10pt;color:#111111"><span>Project Name</span><span></span></td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;background-color:#f6f9fd;padding:3px 4px;font-weight:bold;font-size:10pt;color:#111111"><span>Sub Project</span><span></span></td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;background-color:#f6f9fd;padding:3px 4px;font-weight:bold;font-size:10pt;color:#111111"><span>Project Description</span><span></span></td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;background-color:#f6f9fd;padding:3px 4px;font-weight:bold;font-size:10pt;color:#111111"><span>Drawing Number</span><span></span></td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;background-color:#f6f9fd;padding:3px 4px;font-weight:bold;font-size:10pt;color:#111111"><span>Revision</span><span></span></td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;background-color:#f6f9fd;padding:3px 4px;font-weight:bold;font-size:10pt;color:#111111"><span>Title</span><span></span></td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;background-color:#f6f9fd;padding:3px 4px;font-weight:bold;font-size:10pt;color:#111111"><span>Transmittal</span><span></span></td>
</tr>
</thead>
<tbody style="display:table-row-group">
<tr>
<td nowrap style="border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111"> </td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111" align="right">02-18-2016</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">Rig xxx</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">120</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">Structure</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">00813-121-000-001WM</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">0</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">REAR FRAME</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">02182016</td>
</tr>
<tr style="background-color:#f2f2f2">
<td nowrap style="border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111"> </td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111" align="right">02-18-2016</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">Rig xxx</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">120</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">Structure</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">00813-121-000-000</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">0</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">REAR ASSEMBLY</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">01282016</td>
</tr>
<tr>
<td nowrap style="border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111"> </td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111" align="right">02-18-2016</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">Rig xxx</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">120</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">Structure</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">00813-121-000-001</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">0</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">REAR FRAME</td>
<td style="font-family:Helvetica Neue,Helvetica,Tahoma,Arial,sans-serif;border-left:1px solid #ccc;border-bottom:1px solid #ccc;padding:3px 4px;font-size:10pt;color:#111111">01282016</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</div>
</div>
<br>
If you have trouble using the link above, copy and paste the following Web address into the address bar of your browser:
<br> <a href="somewhere.net" target="_blank">somewhere.net</a>
<br> <br>
This is an automated email from an online application. If you feel that you received this email in error, please contact the application's manager,
<a href="mailto:someone@projects.net" target="_blank">someone@projects.net</a>
</td></tr></table>
</div>
</font></div></table></table></div></div></body></html>