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 with a number of files. The information, including the file is stored
in the database, and an email is sent with the information and any files that
were submitted are attached. The system works fine when a user makes a
submission that has no attachments, and also works when only one file is
attached. However when a second, or subsequent files are attached, I get the
following exception (with the inner exceptions below it).
Could not access 'CDO.Message' object.
Exception has been thrown by the target of an invocation.
Unspecified error
When a user submits a file, it is stored directly to the database, and when
the email is going to be sent, it is retreived from the database and saved in
a temp directory that sits in the application directory. They are then
defined attached to my mail message object using this code:
For Each str In Split(fileNames , "$")
If str <> "" Then
Dim emailAttachment As New MailAttachment( AppSettings("Te mpDir") &
"\" & str)
_emailMessage.A ttachments.Add( emailAttachment )
End If
Next
The exception is thrown when i use the smtpmail.send method. Here is the
code that i am using to create the rest of the MailMessage properties:
_emailMessage.B ody = strBody
'Set the rest of the properties for the email message
_emailMessage.B odyFormat = MailFormat.Html
_emailMessage.F rom = _emailRequest.S ubmitterEmail
_emailMessage.T o = "my*****@co de-example.not-real"
_emailMessage.S ubject = "New information has been submitted"
and is then sent with:
SmtpMail.SmtpSe rver = AppSettings("Em ailRelay")
SmtpMail.Send(_ emailMessage)
Now the bit i don't get is why it is only working with one or less
attachments. I have checked the settings on the IIS SMTP virtual service, and
there is nothign that would stop it from sending more than one attachment,
and the obvious reson i can't troubleshoot this on my own is the unpsecified
error at the bottom of my exception list. Has anyone else had a similar
problem? Any assistance on this would be great! 3 2245
Hi Brian,
Try these two things:
1. Try to give permissions to c:\Documents and Settings\ASPNET \Local
Settings folder on your machine to the authenticated domain user account.
2. Try to give permissions to ASPNET user account on the local folder where
you are storing your attachments.
Since you are able to sent the mail so it looks all the problem because of
permissions, you just double check them. Also check whether the indexing
services is running on your machine sometimes it locks the local folder to
which its indexing and unfortunately at that moment itself your app try to
write into that! Try to stop indexing services and then try you stuff.
Hope this helps.
"Brian Farnhill (MCP VB.NET)" wrote: 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 with a number of files. The information, including the file is stored in the database, and an email is sent with the information and any files that were submitted are attached. The system works fine when a user makes a submission that has no attachments, and also works when only one file is attached. However when a second, or subsequent files are attached, I get the following exception (with the inner exceptions below it).
Could not access 'CDO.Message' object. Exception has been thrown by the target of an invocation. Unspecified error
When a user submits a file, it is stored directly to the database, and when the email is going to be sent, it is retreived from the database and saved in a temp directory that sits in the application directory. They are then defined attached to my mail message object using this code:
For Each str In Split(fileNames , "$") If str <> "" Then Dim emailAttachment As New MailAttachment( AppSettings("Te mpDir") & "\" & str) _emailMessage.A ttachments.Add( emailAttachment ) End If Next
The exception is thrown when i use the smtpmail.send method. Here is the code that i am using to create the rest of the MailMessage properties:
_emailMessage.B ody = strBody
'Set the rest of the properties for the email message _emailMessage.B odyFormat = MailFormat.Html _emailMessage.F rom = _emailRequest.S ubmitterEmail _emailMessage.T o = "my*****@co de-example.not-real" _emailMessage.S ubject = "New information has been submitted"
and is then sent with:
SmtpMail.SmtpSe rver = AppSettings("Em ailRelay") SmtpMail.Send(_ emailMessage)
Now the bit i don't get is why it is only working with one or less attachments. I have checked the settings on the IIS SMTP virtual service, and there is nothign that would stop it from sending more than one attachment, and the obvious reson i can't troubleshoot this on my own is the unpsecified error at the bottom of my exception list. Has anyone else had a similar problem? Any assistance on this would be great!
Hi Hitesh,
When you say give permissions to the authenticated domain user account, do
you mean the account the the email is being sent from? The emails are set to
come from the suer that is using the form, the application uses
impersonation, set in the web.config file with the following tags:
<authenticati on mode="Windows" />
<identity impersonate="tr ue" />
<authorizatio n>
<deny users="?" />
</authorization>
I'm not sure that it is anything to do with permissions on a folder, as the
email will still send with one attachment, its just when i add a second or
more attachments that it fails, but I'll go give that a go, as soon as the
guys that manage the servers let me near the box again! I'll let you know how
I go
- B
"Hitesh" wrote: Hi Brian,
Try these two things:
1. Try to give permissions to c:\Documents and Settings\ASPNET \Local Settings folder on your machine to the authenticated domain user account.
2. Try to give permissions to ASPNET user account on the local folder where you are storing your attachments.
Since you are able to sent the mail so it looks all the problem because of permissions, you just double check them. Also check whether the indexing services is running on your machine sometimes it locks the local folder to which its indexing and unfortunately at that moment itself your app try to write into that! Try to stop indexing services and then try you stuff.
Hope this helps. "Brian Farnhill (MCP VB.NET)" wrote:
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 with a number of files. The information, including the file is stored in the database, and an email is sent with the information and any files that were submitted are attached. The system works fine when a user makes a submission that has no attachments, and also works when only one file is attached. However when a second, or subsequent files are attached, I get the following exception (with the inner exceptions below it).
Could not access 'CDO.Message' object. Exception has been thrown by the target of an invocation. Unspecified error
When a user submits a file, it is stored directly to the database, and when the email is going to be sent, it is retreived from the database and saved in a temp directory that sits in the application directory. They are then defined attached to my mail message object using this code:
For Each str In Split(fileNames , "$") If str <> "" Then Dim emailAttachment As New MailAttachment( AppSettings("Te mpDir") & "\" & str) _emailMessage.A ttachments.Add( emailAttachment ) End If Next
The exception is thrown when i use the smtpmail.send method. Here is the code that i am using to create the rest of the MailMessage properties:
_emailMessage.B ody = strBody
'Set the rest of the properties for the email message _emailMessage.B odyFormat = MailFormat.Html _emailMessage.F rom = _emailRequest.S ubmitterEmail _emailMessage.T o = "my*****@co de-example.not-real" _emailMessage.S ubject = "New information has been submitted"
and is then sent with:
SmtpMail.SmtpSe rver = AppSettings("Em ailRelay") SmtpMail.Send(_ emailMessage)
Now the bit i don't get is why it is only working with one or less attachments. I have checked the settings on the IIS SMTP virtual service, and there is nothign that would stop it from sending more than one attachment, and the obvious reson i can't troubleshoot this on my own is the unpsecified error at the bottom of my exception list. Has anyone else had a similar problem? Any assistance on this would be great!
Hey Hitesh,
OK, Ive tried these things, and it still doesn't work, i get the same error
details. Does anyone else have any other ideas?
- B
"Hitesh" wrote: Hi Brian,
Try these two things:
1. Try to give permissions to c:\Documents and Settings\ASPNET \Local Settings folder on your machine to the authenticated domain user account.
2. Try to give permissions to ASPNET user account on the local folder where you are storing your attachments.
Since you are able to sent the mail so it looks all the problem because of permissions, you just double check them. Also check whether the indexing services is running on your machine sometimes it locks the local folder to which its indexing and unfortunately at that moment itself your app try to write into that! Try to stop indexing services and then try you stuff.
Hope this helps. "Brian Farnhill (MCP VB.NET)" wrote:
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 with a number of files. The information, including the file is stored in the database, and an email is sent with the information and any files that were submitted are attached. The system works fine when a user makes a submission that has no attachments, and also works when only one file is attached. However when a second, or subsequent files are attached, I get the following exception (with the inner exceptions below it).
Could not access 'CDO.Message' object. Exception has been thrown by the target of an invocation. Unspecified error
When a user submits a file, it is stored directly to the database, and when the email is going to be sent, it is retreived from the database and saved in a temp directory that sits in the application directory. They are then defined attached to my mail message object using this code:
For Each str In Split(fileNames , "$") If str <> "" Then Dim emailAttachment As New MailAttachment( AppSettings("Te mpDir") & "\" & str) _emailMessage.A ttachments.Add( emailAttachment ) End If Next
The exception is thrown when i use the smtpmail.send method. Here is the code that i am using to create the rest of the MailMessage properties:
_emailMessage.B ody = strBody
'Set the rest of the properties for the email message _emailMessage.B odyFormat = MailFormat.Html _emailMessage.F rom = _emailRequest.S ubmitterEmail _emailMessage.T o = "my*****@co de-example.not-real" _emailMessage.S ubject = "New information has been submitted"
and is then sent with:
SmtpMail.SmtpSe rver = AppSettings("Em ailRelay") SmtpMail.Send(_ emailMessage)
Now the bit i don't get is why it is only working with one or less attachments. I have checked the settings on the IIS SMTP virtual service, and there is nothign that would stop it from sending more than one attachment, and the obvious reson i can't troubleshoot this on my own is the unpsecified error at the bottom of my exception list. Has anyone else had a similar problem? Any assistance on this would be great! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peter Frost |
last post by:
Please help
I don't know if this is possible but what I would really like to do is
to use On Error Goto to capture the code that is being executed when
an error occurs.
Any help would be much appreciated.
Thanks in advance
|
by: Peter van der Goes |
last post by:
This one has me stumped. I'm looking at support files for a C# textbook,
including three ASP.NET applications that use Access databases. I create
virtual directories for the applications in IIS (running Win XP SP1 and Win
2000 SP4 dual boot - error occurs under either OS), then load the app into
the VS.NET 2003 IDE. When I attempt to run the application, I get the
following error in my browser, instead of the startup page:
Server Error...
|
by: Joachim |
last post by:
I made some project changes (which seems it doesn't help if I undo) which
have created compilation error:
"
Server Error in '/PCSWebApp1' Application.
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
|
by: mark |
last post by:
I have an asp.net ecommerce web application on a remote web server.
I'm using an Access database on the back end. I've notice a few
strange things. When I mimic an multiple user environment by surfin
it in multiple browsers simultaneously the site generates a generic
runtime error after awhile. I'm thinking this has something to do
with my access database and multiple connections. I'm using forms
authentication with a login page. Is...
|
by: JTrigger |
last post by:
When I compile my project using the IDE on a development machine it works
just fine. When I compile it on the server using csc.exe, I get the
following error when I try to bring it up in the web browser. What is the
issue?
Thanks,
Jim
Server Error in '/psnRequest' Application.
----------------------------------------------------------------------------
| |
by: abh1508 |
last post by:
Following a release of code the following problem occurs on certain asp
..net pages. This is not a problem on other testing/demo environments.
IIS seems to be creating certain files twice in the temporary internet
files directory. Any advice or suggestions appreciated.
Server Error in '/ContactCentre/Global' Application.
--------------------------------------------------------------------------------
Compilation Error
|
by: James |
last post by:
Using ASP.NET, I have the following code:
SmtpMail.SmtpServer = "ourmailserver.com"
msgMail.To = "whatever@whatever.com"
msgMail.Attachments.Add(New MailAttachment(SaveLocation))
msgMail.From = "whatever@whatever.com"
msgMail.Subject = tbSubject.Text
|
by: Robert Dufour |
last post by:
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,
|
by: dmjpro |
last post by:
i have no problem while i complile the program.
this is my source code ......
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
class MailTest1
{
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |