Send email with attachment

9 views
Skip to first unread message

Ana

unread,
Dec 18, 2009, 1:34:26 PM12/18/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi,

I need to send an email with attachment, but the attachment is in the
company website. What I'm doing is:

thumbPath = "Folder/Image.jpg"
thumbPath = "www.companywebsite.com/" & thumbPath
Dim attachment As New MailAttachment(thumbPath)

However, the following error message is fired: Invalid mail attachment
'www.companywebsite.com/Folder/Image.jpg'

I typed the thumbPath in the browser and the Image is found in the
website. How to attach this image in my email?

Thanks in advance,

Ana

Arsalan Tamiz

unread,
Dec 18, 2009, 11:21:30 PM12/18/09
to dotnetde...@googlegroups.com
File must be physically attached with email, I think this type of attachment is NOT possible.

You can send email in HTML format and put img tag in there with src = that particular image address. However due to security issues, the end user may NOT able to see images unless he/she allows that.

mateen...@gmail.com

unread,
Dec 19, 2009, 1:53:59 AM12/19/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
hi,

Give the complete path : http://www.websitename/Folder/image.jpg
instead of the relative path

Regards
Mateen

InfRes

unread,
Dec 20, 2009, 5:52:07 PM12/20/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
You have a few options.

1. As above, one option is to use a complete path, this may error
if there is a proxy server between your app and the website.

2. Another option is to download the file to your local machine,
then just check the header to see has it changed, & download it again
if it has...
this way you always have a local file to attach to your email
it may fail with a proxy error as above

3. Yet another option (depending on where your app is running in
relation to the website)
would be to use UNC paths:

\\yourwebserver\your\file\path

This will only be applicable if your website & application are running
in the same network.
you're app will also need permissions to access the network.

Hope this helps

Steve

Łukasz Kuryło

unread,
Dec 20, 2009, 6:46:35 PM12/20/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
>    thumbPath = "Folder/Image.jpg"
>    thumbPath = "www.companywebsite.com/" & thumbPath
>    Dim attachment As New MailAttachment(thumbPath)
>
> However, the following error message is fired: Invalid mail attachment
> 'www.companywebsite.com/Folder/Image.jpg'

Download the file first and then add him to the mail
http://lukaszkurylo.com/archive/2009/10/05/asp.net-asp.net-mvc-snippets.aspx#1

Ana

unread,
Dec 21, 2009, 11:18:14 AM12/21/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
My posted was wrong; in my original code I use the complete path:
http://www.companywebsite.com/Folder/Image.jpg
The error message is fired even with the complete path.

About downloading the image, I don't believe this is the est option
for me. In my application, the user has the option to send 0..n emails
and each one of these email may contain a different Image. Suppose we
have 100 emails to be sent and 70 different Images. This means I would
have to download 70 images from the Company Website and I would have
to do this in the client machine. I don't think this would be the best
solution.

Any other suggestions?

Ana

On Dec 18, 11:53 pm, "veryjo...@yahoo.com" <mateenkapa...@gmail.com>
wrote:

Ana

unread,
Dec 22, 2009, 10:47:09 AM12/22/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Arsalan, I did what you suggested and worked great! Thanks a lot!

On Dec 18, 9:21 pm, Arsalan Tamiz <sallus...@gmail.com> wrote:
> File must be physically attached with email, I think this type of attachment
> is NOT possible.
>
> You can send email in HTML format and put img tag in there with src = that
> particular image address. However due to security issues, the end user may
> NOT able to see images unless he/she allows that.
>

Reply all
Reply to author
Forward
0 new messages