Home All Groups Group Topic Archive Search About

Attachments in VS2003 web mail

Author
28 Nov 2006 6:41 PM
Robert Dufour
In a windows form app the code I got is
Dim AttachItem As String

If MailAttachments <> "" Then  'The fully qualified paths of all the files
that I want to attach

Dim delimStr As String = ";"

Dim delimiter As Char() = delimStr.ToCharArray()

Dim split As String() = Nothing

split = MailAttachments.Split(delimiter)

For Each AttachItem In split

Dim attachment As New MailAttachment(AttachItem) 'create the attachment

mailMsg.Attachments.Add(attachment) 'add the attachment

Next AttachItem

End If

The line

mailMsg.Attachments.Add(attachment) 'add the attachment does not work the
attachment does not get added when I send the mail I get an object not
created error caused by the attachments I tried to add.

What would be the correct syntax?

I've seen Dim attachment As New MailAttachment(Server.MapPath("test.txt"))
'create the attachment but I think that only works for asp pages in my app
in winforms I get Server is not defined.

I had this stuff working OK in framework 2 and vs2005 but because of
limitations imposed by another third party I'm stuck with framework1.1

Thanks for any help

BOB

Author
29 Nov 2006 4:02 AM
Cor Ligthert [MVP]
Robert,

With SMTP their should not be a difference for version 1.1 or 2.0 mostly it
is the IIS SMTP server where is the problem.

Cor

Show quoteHide quote
"Robert Dufour" <bduf***@sgiims.com> schreef in bericht
news:eW$rI0xEHHA.4832@TK2MSFTNGP06.phx.gbl...
> In a windows form app the code I got is
> Dim AttachItem As String
>
> If MailAttachments <> "" Then  'The fully qualified paths of all the files
> that I want to attach
>
> Dim delimStr As String = ";"
>
> Dim delimiter As Char() = delimStr.ToCharArray()
>
> Dim split As String() = Nothing
>
> split = MailAttachments.Split(delimiter)
>
> For Each AttachItem In split
>
> Dim attachment As New MailAttachment(AttachItem) 'create the attachment
>
> mailMsg.Attachments.Add(attachment) 'add the attachment
>
> Next AttachItem
>
> End If
>
> The line
>
> mailMsg.Attachments.Add(attachment) 'add the attachment does not work the
> attachment does not get added when I send the mail I get an object not
> created error caused by the attachments I tried to add.
>
> What would be the correct syntax?
>
> I've seen Dim attachment As New MailAttachment(Server.MapPath("test.txt"))
> 'create the attachment but I think that only works for asp pages in my app
> in winforms I get Server is not defined.
>
> I had this stuff working OK in framework 2 and vs2005 but because of
> limitations imposed by another third party I'm stuck with framework1.1
>
> Thanks for any help
>
> BOB
>
>
>
>