I receive everyday an email which contains some excel tables (about 10rowsx10columns each) and I would like to have them empty keeping formats and labels intact (just erasing cell contents) and store the empty tables in a variable , or a List(Of) in order to eventually fill them.
I tried to store them in a List(Of String) the HTML code which contains the Tag but unfortunately I encountered a lot of various issues regarding the HTML code.
EDIT:
I add the post I already asked for reference, I opened another topic to find another way to accomplish my aim.
Below the sample email content
Is there another way to do it?
Since I was asked for debugging details I attach below coding details.
Function GetMailTable(Subject As String, daysAgo As Integer, ParamArray Keywords() As Object)
Dim myOlApp As New Outlook.Application
Dim objNamespace As Outlook.NameSpace = myOlApp.GetNamespace("MAPI")
Dim objFolder As Outlook.MAPIFolder = objNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Dim itm As Outlook.MailItem
Dim Found As Boolean
Dim strFilter As String
Dim Subj As String = Subject
Dim arrList As ArrayList = New ArrayList
daysAgo = myDate.Subtract(previousBusinessDay(myDate, daysAgo)).TotalDays
strFilter = "@SQL=" & Chr(34) & "urn:schemas:httpmail:subject" & Chr(34) & " like '%" & Subj & "%'"
Dim filtereditemssubj As Object = objFolder.Items.Restrict(strFilter)
Dim filteredItems As Object = filtereditemssubj.Restrict("[ReceivedTime]>'" & Format(myDate.AddDays(-daysAgo), "dd/MM/yyyy") + " 00:00" & "'")
filteredItems = filteredItems.Restrict("[ReceivedTime]<'" & Format(myDate.AddDays(-daysAgo).AddDays(1), "dd/MM/yyyy") + " 00:00" & "'")
Dim htmlDoc As New mshtml.HTMLDocument
Dim tables As mshtml.DispHTMLElementCollection
Dim Table As mshtml.HTMLTable
If filteredItems.Count = 0 Then
Found = False
Else
Found = True
For Each itm In filteredItems
htmlDoc.HTMLBody = itm.HTMLBody
tables = htmlDoc.getElementsByTagName("table")
For Each Table In tables
arrList.Add(Table)
Next Table
Next itm
End If
Return arrList
End Function
This code does not work because I can't get the HTML content of the mail. Is there another viable way to access outlook mails' HTML content or to replicate content and layout of excel's tables included in Outlook mails' body?