Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
VB
mail.Attachments.Add(New Attachment("C:\Users\okookkoko\Desktop\xyz.mdb"))

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

possible to send??
Posted
Updated 24-Mar-18 23:30pm
v4

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.
 
Share this answer
 
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:
VB.NET
expression . Add( Source , Type , Position , DisplayName )
 
Share this answer
 
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.
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900