Is there a way to convert EML file to EmailMessage class/object?
Sure. Use a binaryStream to read all of the EML file into a variable and pass it to source property:
Var mail As New EmailMessage
mail.Source(EML)
Thank you.
Where am I going wrong? here’s my code. I get an error at mail.source(strStreamContent) line.
if folderitemSource <> nil then
try
var bsSource As BinaryStream = BinaryStream.Open(folderitemSource, False)
var strStreamContent As String = bsSource.Read(bsSource.Length)
var mail as new EmailMessage
mail.Source(strStreamContent)
System.DebugLog("From: " + mail.FromAddress)
catch error as IOException
MessageBox(“Can’t read stream”)
end Try
end if
mail.source = strStreamContent seems to work.
maybe the documentation needs to be updated for E mailMessage. I copied the lines from there.
@Sam_Morgan - welcome to the forum!
FYI - you can use the code tag in the post editor…
to format your code:
if folderitemSource <> nil then
try
var bsSource As BinaryStream = BinaryStream.Open(folderitemSource, False)
var strStreamContent As String = bsSource.Read(bsSource.Length)
var mail as new EmailMessage
mail.Source(strStreamContent)
System.DebugLog("From: " + mail.FromAddress)
catch error as IOException
MessageBox(“Can’t read stream”)
end Try
end if
This makes it much easier to read.
Take care,
Anthony
Thanks