[2005] System.Net.Mail.MailMessage to string?
Hello,
I am wondering if System.Net.Mail.MailMessage object can somehow be converted to a string. I am connect to smtp server with a 3rd party component because I am behind firewall that block gmail smtp port. I want connect from proxy to smtp but after I connect I need to send correct headers.
here's what I have:
Code:
Dim nm As New MailMessage
nm.From = New MailAddress("[email protected]")
nm.To.Add("[email protected]")
nm.Subject = "they desperately need to stop the run!"
nm.Body = "the left tackle still looks pretty good though"
Dim TheHead As String = ""
For Each K As String In nm.Headers
TheHead &= K
Next
MsgBox(TheHead)
When I try this I get a blank msgbox everytime. Is what I trying to do possible? Is there any other solution besides constructing the headers by hand?
Re: [2005] System.Net.Mail.MailMessage to string?
That's because the Headers collection doesn't contain String objects. It's a NameValueCollection and they would contain something like KeyValuePair or DictioanryEntry objects. A For Each loop will iterate through those and then you can get the Key and Value properties (or equivalent) of each one.