Results 1 to 4 of 4

Thread: Invalid Cast Ex in SendMail

Hybrid View

  1. #1
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Invalid Cast Ex in SendMail

    Which line throws the exception?

  2. #2

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

    Re: Invalid Cast Ex in SendMail

    Wild Bill

    Here's what shows up:

    VB Code:
    1. Source Error:
    2.  
    3.  
    4. Line 149:        End With
    5. Line 150:
    6. [COLOR=DarkRed]Line 151:        SmtpMail.Send(myMessage)[/COLOR]
    7. Line 152:        lblMessage.Text = "Mail has been sent"
    8. Line 153:    End Sub
    9.  
    10. Source File: ####.aspx    Line: 151
    11.  
    12. Stack Trace:
    13.  
    14.  
    15. [InvalidCastException: Specified cast is not valid.]
    16.    System.Web.Mail.CdoSysHelper.Send(MailMessage message) +769
    17.    System.Web.Mail.SmtpMail.Send(MailMessage message) +153
    Thanks!

    Cdog

  3. #3

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

    Re: Invalid Cast Ex in SendMail

    After 3 beers and 2 pots of coffee -->

    Oops....
    VB Code:
    1. strFolder = "temps/" 'my original goofy line in my upload sub
    2.   strFolder = Server.MapPath("temps/") 'changed it to this

    And added these to the SendMail:

    VB Code:
    1. Dim oAttch1 As MailAttachment = New MailAttachment(StylePath)
    2.         Dim oAttch2 As MailAttachment = New MailAttachment(PicturePath)

    And it seems to be happy goodnight

    Cdog

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