472,354 Members | 2,227 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

Attaching multiple files of any type to a mail message?

I am trying to use framework 1.1 - stuck with it. to send emails from a
windows form application. The email messages can have attachments, usually
two and they can be either text or sounds (wav files) or images (bmp, gif or
tiff)

I can send the email messages OK but the attachments are giving me grief.

Can anyone provide some code that adds attachments to web mail messages.

Thanks for any help,
Bob

Nov 28 '06 #1
5 2295
Robert,

It depends how you sent the email. If you use the default client method, you
cannot use attachment.
If you use SMTP (only on "professional and 2003 OS") than you can use SMTP
mail.

So let us know what you are doing?

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:ey**************@TK2MSFTNGP04.phx.gbl...
>I am trying to use framework 1.1 - stuck with it. to send emails from a
windows form application. The email messages can have attachments, usually
two and they can be either text or sounds (wav files) or images (bmp, gif
or tiff)

I can send the email messages OK but the attachments are giving me grief.

Can anyone provide some code that adds attachments to web mail messages.

Thanks for any help,
Bob

Nov 29 '06 #2
Cor this is the snippet of code that I use so far,
Imports System.Web.Mail

Public Class clsWebMail

Public Sub SendWebMail(ByVal Mailto As String, _

ByVal MailFrom As String, _

ByVal Subject As String, _

ByVal Body As String, _

Optional ByVal MailAttachments As String = "", _

Optional ByVal MailCC As String = "", _

Optional ByVal MailBcc As String = "", _

Optional ByVal ServerName As String = "localhost", _

Optional ByVal UserLogin As String = "", _

Optional ByVal Password As String = "")

'The mail attachments string should contain semi colon delimited full
pathnames

'of the files to be attached.

Try

Dim mailMsg As New MailMessage

With mailMsg

..From = MailFrom

..To = Mailto

..Cc = MailCC

..Bcc = MailBcc

..Subject = Subject

..Body = Body

..Priority = MailPriority.High

End With

Dim AttachItem As String

If MailAttachments <"" Then

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 for
the message

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

Next AttachItem

End If

If ServerName <"localhost" Then

mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",
"1") 'basic authentication

mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",
UserLogin) 'Login name

mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",
"Password") 'set your password here

End If

SmtpMail.SmtpServer = ServerName

SmtpMail.Send(mailMsg)

Catch ex As Exception

WriteLogEntry("Application", "WebMailing", "Web mail send error " &
ex.InnerException.Message, EventLogEntryType.Error, 0, 0)

End Try

End Sub

End Class

The code works OK except when I try to use the attachments. The project
needs to work on a Windows XP Pro or Windows 2000 workstation, it is not
intended for a 2003 server. I know that in 2005 the mailing has been moved
to SYSTEM.NET.MAIL but I'm stuck with using VS2003 that uses
system.web.mail.
I found some info and code samples at
http://www.systemwebmail.com/faq/2.3.aspx but the attachments don't work and
I need it, badly.

Bob

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Robert,

It depends how you sent the email. If you use the default client method,
you cannot use attachment.
If you use SMTP (only on "professional and 2003 OS") than you can use SMTP
mail.

So let us know what you are doing?

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:ey**************@TK2MSFTNGP04.phx.gbl...
>>I am trying to use framework 1.1 - stuck with it. to send emails from a
windows form application. The email messages can have attachments, usually
two and they can be either text or sounds (wav files) or images (bmp, gif
or tiff)

I can send the email messages OK but the attachments are giving me grief.

Can anyone provide some code that adds attachments to web mail messages.

Thanks for any help,
Bob


Nov 29 '06 #3
Robert,

The first thing I thought on was "Is Robert using HTML post, because that
preservers the charachters"
Almost nobody likes that but as you have to do that, than you have no
alternatives.

At the moment I don't have the time to check your code but this is the best
website with information about your problem. If nobody else is checking your
code and you keeps the problem, than please reply I can than see if I have
the time to check it in the weekend.

http://www.systemwebmail.net/

Cor
..


"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:ug**************@TK2MSFTNGP02.phx.gbl...
Cor this is the snippet of code that I use so far,
Imports System.Web.Mail

Public Class clsWebMail

Public Sub SendWebMail(ByVal Mailto As String, _

ByVal MailFrom As String, _

ByVal Subject As String, _

ByVal Body As String, _

Optional ByVal MailAttachments As String = "", _

Optional ByVal MailCC As String = "", _

Optional ByVal MailBcc As String = "", _

Optional ByVal ServerName As String = "localhost", _

Optional ByVal UserLogin As String = "", _

Optional ByVal Password As String = "")

'The mail attachments string should contain semi colon delimited full
pathnames

'of the files to be attached.

Try

Dim mailMsg As New MailMessage

With mailMsg

.From = MailFrom

.To = Mailto

.Cc = MailCC

.Bcc = MailBcc

.Subject = Subject

.Body = Body

.Priority = MailPriority.High

End With

Dim AttachItem As String

If MailAttachments <"" Then

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
for the message

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

Next AttachItem

End If

If ServerName <"localhost" Then

mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",
"1") 'basic authentication

mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",
UserLogin) 'Login name

mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",
"Password") 'set your password here

End If

SmtpMail.SmtpServer = ServerName

SmtpMail.Send(mailMsg)

Catch ex As Exception

WriteLogEntry("Application", "WebMailing", "Web mail send error " &
ex.InnerException.Message, EventLogEntryType.Error, 0, 0)

End Try

End Sub

End Class

The code works OK except when I try to use the attachments. The project
needs to work on a Windows XP Pro or Windows 2000 workstation, it is not
intended for a 2003 server. I know that in 2005 the mailing has been moved
to SYSTEM.NET.MAIL but I'm stuck with using VS2003 that uses
system.web.mail.
I found some info and code samples at
http://www.systemwebmail.com/faq/2.3.aspx but the attachments don't work
and I need it, badly.

Bob

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Robert,

It depends how you sent the email. If you use the default client method,
you cannot use attachment.
If you use SMTP (only on "professional and 2003 OS") than you can use
SMTP mail.

So let us know what you are doing?

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:ey**************@TK2MSFTNGP04.phx.gbl...
>>>I am trying to use framework 1.1 - stuck with it. to send emails from a
windows form application. The email messages can have attachments,
usually two and they can be either text or sounds (wav files) or images
(bmp, gif or tiff)

I can send the email messages OK but the attachments are giving me
grief.

Can anyone provide some code that adds attachments to web mail messages.

Thanks for any help,
Bob



Nov 30 '06 #4
Cor
I looked at that site and that's where I picked up on how to do it. I did
some more testing with my code and I found that the attachments work OK when
I use localhost (i.e the built-in SMTP server that gets installed with IIS).
But I find that if I try to use an outside mail server like
mail.mycompany.com which is outside my LAN and requires a logon user name
and password, then I can't send mail messages to which I try to attach files
using my code, however if I don't try to use attachments the mail message
gets sent OK. It seems to mean that somehow one needs to do some other code
when trying to make attachments to a remote server. I could not find any
documentation or sample code on that specific problem.

Regards,
Bob
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:OV**************@TK2MSFTNGP02.phx.gbl...
Robert,

The first thing I thought on was "Is Robert using HTML post, because that
preservers the charachters"
Almost nobody likes that but as you have to do that, than you have no
alternatives.

At the moment I don't have the time to check your code but this is the
best website with information about your problem. If nobody else is
checking your code and you keeps the problem, than please reply I can than
see if I have the time to check it in the weekend.

http://www.systemwebmail.net/

Cor
.


"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:ug**************@TK2MSFTNGP02.phx.gbl...
>Cor this is the snippet of code that I use so far,
Imports System.Web.Mail

Public Class clsWebMail

Public Sub SendWebMail(ByVal Mailto As String, _

ByVal MailFrom As String, _

ByVal Subject As String, _

ByVal Body As String, _

Optional ByVal MailAttachments As String = "", _

Optional ByVal MailCC As String = "", _

Optional ByVal MailBcc As String = "", _

Optional ByVal ServerName As String = "localhost", _

Optional ByVal UserLogin As String = "", _

Optional ByVal Password As String = "")

'The mail attachments string should contain semi colon delimited full
pathnames

'of the files to be attached.

Try

Dim mailMsg As New MailMessage

With mailMsg

.From = MailFrom

.To = Mailto

.Cc = MailCC

.Bcc = MailBcc

.Subject = Subject

.Body = Body

.Priority = MailPriority.High

End With

Dim AttachItem As String

If MailAttachments <"" Then

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
for the message

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

Next AttachItem

End If

If ServerName <"localhost" Then

mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",
"1") 'basic authentication

mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",
UserLogin) 'Login name

mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",
"Password") 'set your password here

End If

SmtpMail.SmtpServer = ServerName

SmtpMail.Send(mailMsg)

Catch ex As Exception

WriteLogEntry("Application", "WebMailing", "Web mail send error " &
ex.InnerException.Message, EventLogEntryType.Error, 0, 0)

End Try

End Sub

End Class

The code works OK except when I try to use the attachments. The project
needs to work on a Windows XP Pro or Windows 2000 workstation, it is not
intended for a 2003 server. I know that in 2005 the mailing has been
moved to SYSTEM.NET.MAIL but I'm stuck with using VS2003 that uses
system.web.mail.
I found some info and code samples at
http://www.systemwebmail.com/faq/2.3.aspx but the attachments don't work
and I need it, badly.

Bob

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>Robert,

It depends how you sent the email. If you use the default client method,
you cannot use attachment.
If you use SMTP (only on "professional and 2003 OS") than you can use
SMTP mail.

So let us know what you are doing?

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:ey**************@TK2MSFTNGP04.phx.gbl...
I am trying to use framework 1.1 - stuck with it. to send emails from a
windows form application. The email messages can have attachments,
usually two and they can be either text or sounds (wav files) or images
(bmp, gif or tiff)

I can send the email messages OK but the attachments are giving me
grief.

Can anyone provide some code that adds attachments to web mail
messages.

Thanks for any help,
Bob





Dec 1 '06 #5
Bob,

That sounds very strange to me and looks just like a firewall or
virusscanner problem, as there are often in this situations.

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:OS**************@TK2MSFTNGP06.phx.gbl...
Cor
I looked at that site and that's where I picked up on how to do it. I did
some more testing with my code and I found that the attachments work OK
when I use localhost (i.e the built-in SMTP server that gets installed
with IIS). But I find that if I try to use an outside mail server like
mail.mycompany.com which is outside my LAN and requires a logon user name
and password, then I can't send mail messages to which I try to attach
files using my code, however if I don't try to use attachments the mail
message gets sent OK. It seems to mean that somehow one needs to do some
other code when trying to make attachments to a remote server. I could not
find any documentation or sample code on that specific problem.

Regards,
Bob
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:OV**************@TK2MSFTNGP02.phx.gbl...
>Robert,

The first thing I thought on was "Is Robert using HTML post, because that
preservers the charachters"
Almost nobody likes that but as you have to do that, than you have no
alternatives.

At the moment I don't have the time to check your code but this is the
best website with information about your problem. If nobody else is
checking your code and you keeps the problem, than please reply I can
than see if I have the time to check it in the weekend.

http://www.systemwebmail.net/

Cor
.


"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:ug**************@TK2MSFTNGP02.phx.gbl...
>>Cor this is the snippet of code that I use so far,
Imports System.Web.Mail

Public Class clsWebMail

Public Sub SendWebMail(ByVal Mailto As String, _

ByVal MailFrom As String, _

ByVal Subject As String, _

ByVal Body As String, _

Optional ByVal MailAttachments As String = "", _

Optional ByVal MailCC As String = "", _

Optional ByVal MailBcc As String = "", _

Optional ByVal ServerName As String = "localhost", _

Optional ByVal UserLogin As String = "", _

Optional ByVal Password As String = "")

'The mail attachments string should contain semi colon delimited full
pathnames

'of the files to be attached.

Try

Dim mailMsg As New MailMessage

With mailMsg

.From = MailFrom

.To = Mailto

.Cc = MailCC

.Bcc = MailBcc

.Subject = Subject

.Body = Body

.Priority = MailPriority.High

End With

Dim AttachItem As String

If MailAttachments <"" Then

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
for the message

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

Next AttachItem

End If

If ServerName <"localhost" Then

mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",
"1") 'basic authentication

mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",
UserLogin) 'Login name

mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",
"Password") 'set your password here

End If

SmtpMail.SmtpServer = ServerName

SmtpMail.Send(mailMsg)

Catch ex As Exception

WriteLogEntry("Application", "WebMailing", "Web mail send error " &
ex.InnerException.Message, EventLogEntryType.Error, 0, 0)

End Try

End Sub

End Class

The code works OK except when I try to use the attachments. The project
needs to work on a Windows XP Pro or Windows 2000 workstation, it is not
intended for a 2003 server. I know that in 2005 the mailing has been
moved to SYSTEM.NET.MAIL but I'm stuck with using VS2003 that uses
system.web.mail.
I found some info and code samples at
http://www.systemwebmail.com/faq/2.3.aspx but the attachments don't work
and I need it, badly.

Bob

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl.. .
Robert,

It depends how you sent the email. If you use the default client
method, you cannot use attachment.
If you use SMTP (only on "professional and 2003 OS") than you can use
SMTP mail.

So let us know what you are doing?

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:ey**************@TK2MSFTNGP04.phx.gbl...
>I am trying to use framework 1.1 - stuck with it. to send emails from a
>windows form application. The email messages can have attachments,
>usually two and they can be either text or sounds (wav files) or images
>(bmp, gif or tiff)
>
I can send the email messages OK but the attachments are giving me
grief.
>
Can anyone provide some code that adds attachments to web mail
messages.
>
Thanks for any help,
Bob
>
>
>




Dec 2 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: .: DeVa :. | last post by:
How can i brows for picture on disk and then save it into array for mailing ? ------ www.podvodni-svijet.com "Half-brother in blood, full brother in heart will I be. Thou shalt lead and I...
5
by: Ron Brennan | last post by:
Good afternoon. The entire task that I'm trying to achieve is to allow a user to browse and upload multiple files simultaneously, hiding the Browse button of <input> tags of type="file" and...
2
by: Marcus | last post by:
I have seen many posts of people with the same problem as me (attached below), but I have yet to see any solutions posted. Has anyone figured out how to deploy an Asp.net web site to the webserver...
3
by: Brian Farnhill (MCP VB.NET) | last post by:
Hi, I am having some trouble using the MailMessage object to send an email with more than one attachment. I am working on a web based application where a user can submit information, along...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
0
by: wal | last post by:
How does one attach files to emails using libgmail? The following code http://pramode.net/articles/lfy/fuse/4.txt works fine when said files are simple text files, but it failes as soon as the...
6
by: Harshpandya | last post by:
Hi all, I am working on the form in which you fill out the whole PHP form and e mail that details to someone. It is working fine. But now i want to send the same form to be sent to different...
3
by: zaxxon25 | last post by:
I am having an issue with attaching 2 attachments one xip and other excel file with email and sending using perl sendmail. I tried to look on various forums and everywhere i get advice using MIME ::...
1
by: deepaks85 | last post by:
Dear All, I want to send some data through a form with Multiple attachment in an HTML Format. I have tried it but it is not working for me. I am able to send data without attachment but with the...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.