Results 1 to 4 of 4

Thread: Invalid Cast Ex in SendMail

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member Rocketdawg's Avatar
    Join Date
    Feb 2003
    Location
    Back in the doghouse
    Posts
    294

    Invalid Cast Ex in SendMail

    Hi Everyone

    I'm having a bit of trouble getting a routine to work and I can't quite figure out whats wrong. It keeps throwing an 'invalid cast exception'. Any ideas? Thanks,

    Cdog

    VB Code:
    1. Sub SendMailProcessing()
    2.         Dim myMessage As New MailMessage
    3.         Dim str As New StringBuilder
    4.         Dim StylePath As String = Session("MyStylePath") 'path to an uploaded pic
    5.         Dim PicturePath As String = Session("MyPicturePath")'path to an uploaded pic
    6.  
    7.         MyList = Session("List")
    8.  
    9.         'build the body of the email
    10.         str.Append("First Name: " & MyList("First_Name") & ControlChars.CrLf)
    11.         str.Append("Last Name: " & MyList("Last_Name") & ControlChars.CrLf)
    12.         str.Append("Address: " & MyList("Address") & ControlChars.CrLf)
    13.         str.Append("Apartment Number: " & MyList("Apt") & ControlChars.CrLf)
    14.         str.Append("City: " & MyList("City") & ControlChars.CrLf)
    15.         str.Append("State: " & MyList("State") & ControlChars.CrLf)
    16.         str.Append("Zip: " & MyList("Zip") & ControlChars.CrLf)
    17.         str.Append("Phone: " & MyList("Phone") & ControlChars.CrLf)
    18.         str.Append("Email: " & MyList("Email") & ControlChars.CrLf & ControlChars.CrLf)
    19.         str.Append("BaseColor: " & MyList("Base_Color") & ControlChars.CrLf)
    20.         str.Append("Hair Type: " & MyList("Hair_Type") & ControlChars.CrLf)
    21.         str.Append("Wave Type: " & MyList("Wave_Type") & ControlChars.CrLf)
    22.         str.Append("Front to back measurement: " & MyList("Front_to_Back_Measurement") & ControlChars.CrLf)
    23.         str.Append("Side to side measurement: " & MyList("Side_to_Side_Measurement") & ControlChars.CrLf)
    24.         str.Append("Top Length: " & MyList("Top_Length") & ControlChars.CrLf)
    25.         str.Append("Front_Length: " & MyList("Front_Length") & ControlChars.CrLf)
    26.         str.Append("Side Length: " & MyList("Side_Length") & ControlChars.CrLf)
    27.         str.Append("Back Length: " & MyList("Back_Length") & ControlChars.CrLf & ControlChars.CrLf)
    28.         str.Append("Special Instructions: " & MyList("Special_Instructions") & ControlChars.CrLf)
    29.         With myMessage
    30.             .To = "[email protected]"
    31.             .From = MyList("Email")
    32.             .Subject = "Incoming Order"
    33.             .Body = str.ToString
    34.             .BodyFormat = MailFormat.Text
    35.             If StylePath <> "" Then
    36.                 .Attachments.Add(StylePath)
    37.             End If
    38.             If PicturePath <> "" Then
    39.                 .Attachments.Add(PicturePath)
    40.             End If
    41.         End With
    42.  
    43.         SmtpMail.Send(myMessage)
    44.  
    45.     End Sub
    Last edited by Rocketdawg; Aug 11th, 2005 at 06:58 PM. Reason: addition to post

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