vba - 如何从电子邮件中提取数据?
问题描述
我收到包含以下数据的电子邮件:
您的 EagleView 测量已准备好接受以下订单:
•<br /> • 报告 ID:26048369(高级版,60.00 美元,4740 平方英尺)
• 地址:123 Apple St, City, FL 32456-####
我需要获取地址“123 Apple St”并将其放入稍后调用的变量中。
我明白了
运行时错误 13 类型不匹配。
运行此代码时:
Sub Extract()
'Define Variables
Dim sFileName As String
Dim Address As Variant
Set myfolder = Outlook.ActiveExplorer.CurrentFolder
For i = 1 To myfolder.Items.Count
Set myitem = myfolder.Items(i)
msgtext = myitem.Body
'Search for specific Text
delimitedMessage = Replace(msgtext, "Address: ", "###")
delimitedMessage = Replace(delimitedMessage, ",", "###")
Address = Split(delimitedMessage, "###")
'Alert box showing if the code worked
MsgBox "The Address is: " + Address
Next
End Sub
解决方案
'Address' 是一个字符串数组,因此当您尝试显示它时会引发错误。您需要数组的第四个元素,它是零索引的。只需替换MsgBox "The Address is: " + Address
为MsgBox "The Address is: " + Address(3)
推荐阅读
- python - chromedriver版本> 74的MoveTargetOutOfBoundsException问题
- python - 极地散点图不绘制最后一列
- javascript - react native绘制图表时如何在Svg Path中使用PanGestureHandler
- java - How to set HADOOP_CLASSPATH for using the local filesystem with a local job runner?
- django - 向查询集序列化程序添加额外字段
- php - 使用 API JSON 根据第一个下拉列表填充第二个下拉列表
- flutter - 如何将视频放入 listview builder 中?
- spring-boot - java.lang.NoSuchMethodError: org.mockito.MockingDetails.getMockCreationSettings() - Gradle links same class twice for Mockito jar
- javascript - 突出列差异
- r - Set date value in time series based on value in previous row