Click here to Skip to main content
14,421,753 members
Rate this:
Please Sign up or sign in to vote.
See more:
HI I have made a software that has to mail the *.mdb File in my bin folder of the Application.When i attach a jpg file to this mail the Mail is sent successfully but when i attach an MDB file (Microsoft Access File) then i get an Exception "An invalid file attachment ...Niigata.mdb" where Niigata.mdb is my Access file that i want to mail.
Can anybody please help me with this problem.

What I have tried:

i am using this code for sending mail.
mail.Attachments.Add(New Attachment("C:\Users\okookkoko\Desktop\xyz.mdb"))

not possible to send
mail.Attachments.Add(New Attachment("C:\Users\okookkoko\Desktop\image.jpg"))

possible to send??
Updated 25-Mar-18 0:30am
Rate this:
Please Sign up or sign in to vote.

Solution 1

If the JPG file goes, and the MDB file doesn't there are a couple of possibilities:
1) The MDB file is in use and can;t be opened in order to copy it into the email. Check your code and see if you leave any Connection objects unclosed, and undisposed. If your app is "holding" the file, it won;t be openable by the email system.
2) The file is too big for your email system rules. Some systems will restrict the size of outgoing emails so you don't annoy the heck out of people with slow / expensive data connections. Check the file size, and look at your email system rules.
Rate this:
Please Sign up or sign in to vote.

Solution 2

If you're talking about Outlook, check this: How to: Programmatically Attach Files to Outlook E-Mail Items[^]
As the documentation[^] states, Attachments.Add method gets 4 parameters:
expression . Add( Source , Type , Position , DisplayName )
Rate this:
Please Sign up or sign in to vote.

Solution 3

Size of attachments is limited in mails, and that is your problem, it's your ISP.
Mostly 2 solutions:
- find a mailing tool that can slice your attachment in parts and make multiple mails according to the size limit.
- use some kind of 'DropBox' service to store your file on internet and send a link to your file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100