Results 1 to 2 of 2

Thread: [2005] System.Net.Mail.MailMessage to string?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    8

    Arrow [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?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width