sending mail pb

F

fhranck

hello
I am using the following code in a windows .net application
and it returns me:
"Exception has been thrown by the target of an invocation."
---------------- code
MailMessage msg=new MailMessage();
message.From="email";
message.To="email";
message.Subject="test" ;
message.Body="test";
SmtpMail.SmtpServer="smtp.email.com";
SmtpMail.Send(msg);
------------------
I tried severall things disabeld the firewall
even copied and paste this code in a webform and it worked!!!!
this code is only not working in a windows application....


The exception is :

InnerException {System.Runtime.InteropServices.COMException}
System.Exception Message
"Exception has been thrown by the target of an invocation."
Source "mscorlib"
StackTrace " at System.RuntimeType.InvokeDispMethod(String name,
BindingFlags invokeAttr, Object target, Object[] args, Boolean[]
byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object
obj, String methodName, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)"

any ideas?

Thanks for your help
 
L

Lars Behrmann

Hi,

have you add the System.Web.dll to your project references? If
you only use using System.Web without referencing the dll.
the call will fail.

Cheers
Lars Behrmann

_________________
Nothing is impossible. UML is the key for all your problems.
AODL - Make your .net apps OpenOffice ready
http://aodl.sourceforge.net/
 
F

fhranck

Hello Lars,
thanks for your suggestion, I added the reference
but the error is the same

Lars Behrmann said:
Hi,

have you add the System.Web.dll to your project references? If
you only use using System.Web without referencing the dll.
the call will fail.

Cheers
Lars Behrmann

_________________
Nothing is impossible. UML is the key for all your problems.
AODL - Make your .net apps OpenOffice ready
http://aodl.sourceforge.net/
hello
I am using the following code in a windows .net application
and it returns me:
"Exception has been thrown by the target of an invocation."
---------------- code
MailMessage msg=new MailMessage();
message.From="email";
message.To="email";
message.Subject="test" ;
message.Body="test";
SmtpMail.SmtpServer="smtp.email.com";
SmtpMail.Send(msg);
------------------
I tried severall things disabeld the firewall
even copied and paste this code in a webform and it worked!!!!
this code is only not working in a windows application....


The exception is :

InnerException {System.Runtime.InteropServices.COMException}
System.Exception Message
"Exception has been thrown by the target of an invocation."
Source "mscorlib"
StackTrace " at System.RuntimeType.InvokeDispMethod(String name,
BindingFlags invokeAttr, Object target, Object[] args, Boolean[]
byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[]
modifiers,
CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder
binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object
obj, String methodName, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)"

any ideas?

Thanks for your help
 
V

Vadym Stetsyak

Are there any HRESULT codes int the exception or in the inner exception?

Under what users application is working? Admin?
 
F

fhranck

thanks for your replie

I am running the application as Adminstrator.

please find the entire exception message:
I havn't find any HRESULT code:

************** Exception Text **************
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040213): The transport
failed to connect to the server.

--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32
culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at TestModBUs.frmProtocole.Button1_Click(Object sender, EventArgs e) in
C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\IDE\TestModBUs\frmProtocole.vb:line 127
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
TestModBUs
Assembly Version: 1.0.2153.20658
Win32 Version: 1.0.2153.20658
CodeBase:
file:///C:/Program%20Files/Microsoft%20Visual%20Studio%20.NET%202003/Common7/IDE/TestModBUs/bin/TestModBUs.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
System.Web
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2037
CodeBase:
file:///c:/windows/assembly/gac/system.web/1.0.5000.0__b03f5f7f11d50a3a/system.web.dll
----------------------------------------

Vadym Stetsyak said:
Are there any HRESULT codes int the exception or in the inner exception?

Under what users application is working? Admin?

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com


fhranck said:
hello
I am using the following code in a windows .net application
and it returns me:
"Exception has been thrown by the target of an invocation."
---------------- code
MailMessage msg=new MailMessage();
message.From="email";
message.To="email";
message.Subject="test" ;
message.Body="test";
SmtpMail.SmtpServer="smtp.email.com";
SmtpMail.Send(msg);
------------------
I tried severall things disabeld the firewall
even copied and paste this code in a webform and it worked!!!!
this code is only not working in a windows application....


The exception is :

InnerException {System.Runtime.InteropServices.COMException}
System.Exception Message
"Exception has been thrown by the target of an invocation."
Source "mscorlib"
StackTrace " at System.RuntimeType.InvokeDispMethod(String name,
BindingFlags invokeAttr, Object target, Object[] args, Boolean[]
byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object
obj, String methodName, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)"

any ideas?

Thanks for your help
 
V

Vadym Stetsyak

The HRESULT is 0x80040213

This exception states that SmtpMail cannot connect to server. Is that server
operational?

Have a look at the following links
( http://www.dotnet247.com/247reference/msgs/19/95438.aspx )
( http://www.experts-exchange.com/Web/Q_21127523.html )

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com


fhranck said:
thanks for your replie

I am running the application as Adminstrator.

please find the entire exception message:
I havn't find any HRESULT code:

************** Exception Text **************
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040213): The transport
failed to connect to the server.

--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32
culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at TestModBUs.frmProtocole.Button1_Click(Object sender, EventArgs e) in
C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\IDE\TestModBUs\frmProtocole.vb:line 127
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
TestModBUs
Assembly Version: 1.0.2153.20658
Win32 Version: 1.0.2153.20658
CodeBase:
file:///C:/Program%20Files/Microsoft%20Visual%20Studio%20.NET%202003/Common7/IDE/TestModBUs/bin/TestModBUs.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
System.Web
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2037
CodeBase:
file:///c:/windows/assembly/gac/system.web/1.0.5000.0__b03f5f7f11d50a3a/system.web.dll
----------------------------------------

Vadym Stetsyak said:
Are there any HRESULT codes int the exception or in the inner exception?

Under what users application is working? Admin?

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com


fhranck said:
hello
I am using the following code in a windows .net application
and it returns me:
"Exception has been thrown by the target of an invocation."
---------------- code
MailMessage msg=new MailMessage();
message.From="email";
message.To="email";
message.Subject="test" ;
message.Body="test";
SmtpMail.SmtpServer="smtp.email.com";
SmtpMail.Send(msg);
------------------
I tried severall things disabeld the firewall
even copied and paste this code in a webform and it worked!!!!
this code is only not working in a windows application....


The exception is :

InnerException {System.Runtime.InteropServices.COMException}
System.Exception Message
"Exception has been thrown by the target of an invocation."
Source "mscorlib"
StackTrace " at System.RuntimeType.InvokeDispMethod(String name,
BindingFlags invokeAttr, Object target, Object[] args, Boolean[]
byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object
obj, String methodName, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)"

any ideas?

Thanks for your help
 
F

fhranck

Yes the SmtpMail sever is working as the same code
is working in a webform.aspx


Vadym Stetsyak said:
The HRESULT is 0x80040213

This exception states that SmtpMail cannot connect to server. Is that
server
operational?

Have a look at the following links
( http://www.dotnet247.com/247reference/msgs/19/95438.aspx )
( http://www.experts-exchange.com/Web/Q_21127523.html )

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com


fhranck said:
thanks for your replie

I am running the application as Adminstrator.

please find the entire exception message:
I havn't find any HRESULT code:

************** Exception Text **************
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040213): The transport
failed to connect to the server.

--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32
culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at TestModBUs.frmProtocole.Button1_Click(Object sender, EventArgs e)
in
C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\IDE\TestModBUs\frmProtocole.vb:line 127
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
TestModBUs
Assembly Version: 1.0.2153.20658
Win32 Version: 1.0.2153.20658
CodeBase:
file:///C:/Program%20Files/Microsoft%20Visual%20Studio%20.NET%202003/Common7/IDE/TestModBUs/bin/TestModBUs.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
System.Web
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2037
CodeBase:
file:///c:/windows/assembly/gac/system.web/1.0.5000.0__b03f5f7f11d50a3a/system.web.dll
----------------------------------------

Vadym Stetsyak said:
Are there any HRESULT codes int the exception or in the inner
exception?

Under what users application is working? Admin?

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com


hello
I am using the following code in a windows .net application
and it returns me:
"Exception has been thrown by the target of an invocation."
---------------- code
MailMessage msg=new MailMessage();
message.From="email";
message.To="email";
message.Subject="test" ;
message.Body="test";
SmtpMail.SmtpServer="smtp.email.com";
SmtpMail.Send(msg);
------------------
I tried severall things disabeld the firewall
even copied and paste this code in a webform and it worked!!!!
this code is only not working in a windows application....


The exception is :

InnerException {System.Runtime.InteropServices.COMException}
System.Exception Message
"Exception has been thrown by the target of an invocation."
Source "mscorlib"
StackTrace " at System.RuntimeType.InvokeDispMethod(String
name,
BindingFlags invokeAttr, Object target, Object[] args, Boolean[]
byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[]
modifiers,
CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder
binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object
obj, String methodName, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)"

any ideas?

Thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top