Advertisement

11.05.2007 at 10:19AM PST, ID: 22939773
[x]
Attachment Details

SMTP E-mail attachment issue

Asked by smagnus1 in Simple Mail Transfer Protocol (SMTP), SendMail Email Server, Email Servers

Tags: smtp

Hi all,

I have the following code for performing an e-mail message:

 Dim mailMsg As New MailMessage
        With mailMsg
            .From = "DailyMaintenanceReport@whoever.com"
            .To = "whoever@whoever.com"
            .Subject = "Daily Maintenance Report as of " & Now
            .Body = "Attached is your daily report"
           .Attachments.Add("C:\Test\Book1.doc")
        End With

        SmtpMail.SmtpServer = "CorportateSMTPServer"

        Try
            '    Dim x As Integer
            SmtpMail.Send(mailMsg)

        Catch exp As Exception
            TextBox1.Text = exp.Message
            MsgBox("Ugh Oh")
        End Try

My delimma is, the code works great, until the attachment is added to the message.  Once the attachment is added, I get the following message:

Specified cast is not valid.

Any help would be greatly appreciated.  Thanks in advance.Start Free Trial
[+][-]11.05.2007 at 10:41AM PST, ID: 20218265

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Simple Mail Transfer Protocol (SMTP), SendMail Email Server, Email Servers
Tags: smtp
Sign Up Now!
Solution Provided By: smagnus1
Participating Experts: 0
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628