[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

Alternative to a reporting tool?

I'm up against a deadline and am having way too much difficulty finding a simple free reporting solution to my ASP .NET 3.5 [C#] web application. So in an effort to "come up with something" i'm now playing with  the idea of creating a formatted message and just sending that formatted message through an email. So,...I'm now looking for code examples or links that point to examples of how to do this? Any help would be appreciated. If it adds any help to the solution, i'm running my web app from / through a goDaddy server. Thanks.
0
Michael Sterling
Asked:
Michael Sterling
  • 6
  • 4
1 Solution
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
here's a simple tutorial on how to send emails:

http://www.systemwebmail.com/faq/2.2.aspx
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
if you need to use authentication, this thread also explains it well:

http://social.msdn.microsoft.com/Forums/en/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
@The Big Daddy: so how do i make sure that I'm set up correctly to send email from my HostIPAddress or smptserver? i'm getting a socket operation error: "A socket operation was attempted to an unreachable network xxx.xxx.x.x:25". and for some reason there is a :25 attached to the end of my IP octet. Not sure why or what this error means. I went and ran the "ipconfig /all" command from the command prompt to get my DNS server IP address. and when i put that in my code for my local host, as in the sample code above, it bombed out with the error mentioned above.

i had to alter the code a bit,...(see code attached). i set the HostIPAddress to the ip address i found when i ran the ipconfig /all command
MailAddress toAddress = new MailAddress("toAddress@gmail.com");
        MailAddress fromAddress = new MailAddress("fromAddress@gmail.com");

        System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(fromAddress, toAddress);
        //mail.To.Add(toAddress);
        //mail.From.Address;
        mail.Subject = "this is a test email.";
        mail.IsBodyHtml = true;
        mail.Body = "this is my test email body.<br><b>this part is in bold</b>";

        using (SmtpClient client = new SmtpClient(String.IsNullOrEmpty(smtpserver) ? HostIPAddress : smtpserver)) //your real server goes here
        {
            client.Send(mail);

        }

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
since you're hosting on GoDaddy, you'll need to use their servers to send out the email. After some digging around, I found this article:

http://help.godaddy.com/article/1073

Note you cant use gMail addresses to send emails.
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
ok,...I will check that link for when I start testing on goDaddy. for now, the problem I described above, is happening as I try to test the code on my machine, my laptop. I'm using a wireless connection, if that makes any difference.
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
this is the copied and pasted text of the error i'm getting (see code snippet). above, when you mentioned that i couldn't send email from my gMail account, was that pertaining only to if i was / would be trying to send an e-mail through the goDaddy server(s)?
Server Error in '/' Application.
A socket operation was attempted to an unreachable network xxx.xxx.x.xxx:25
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: A socket operation was attempted to an unreachable network 192.168.1.100:25

Source Error:

Line 1607:        SmtpClient client = new SmtpClient(HostIPAddress); //your real server goes here
Line 1608:
Line 1609:            client.Send(mail);
Line 1610:
Line 1611:        if (rbtnLockPassword.Checked)


Source File: c:\src\StudyTimeTrackerPrimeI\Default.aspx.cs    Line: 1609

Stack Trace:

[SocketException (0x2743): A socket operation was attempted to an unreachable network 192.168.1.100:25]
   System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
   System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
   System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224

[WebException: Unable to connect to the remote server]
   System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +5495895
   System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +202
   System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +21
   System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +332
   System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +160
   System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +159
   System.Net.Mail.SmtpClient.GetConnection() +35
   System.Net.Mail.SmtpClient.Send(MailMessage message) +1213

[SmtpException: Failure sending mail.]
   System.Net.Mail.SmtpClient.Send(MailMessage message) +1531
   _Default.StudentSignInOut() in c:\src\StudyTimeTrackerPrimeI\Default.aspx.cs:1609
   _Default.btnSignIn_click(Object sender, EventArgs e) in c:\src\StudyTimeTrackerPrimeI\Default.aspx.cs:1540
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


Version Information: Microsoft .NET Framework Version:2.0.50727.5446; ASP.NET Version:2.0.50727.5420

Open in new window

0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
thats correct, GD doesnt allow it for some reason.

the error you're getting is basically saying the address you provided is incorrect. Whether its the port number(25) thats throwing it off or just the wrong IP, im not sure, you'll have to play around with it. did you try using just localhost as your address with the latest example I gave you?
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
if you mean actually putting in the string: "localhost" no i didn't / haven't. but i will now and let you know what happens...
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
i got a transport error when i tried it with "localhost"
Server Error in '/' Application.
The transport failed to connect to the server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The transport failed to connect to the server.


Source Error:

Line 1610:        SmtpMail.SmtpServer = "localhost"; //your real server goes here
Line 1611:
Line 1612:        SmtpMail.Send(mail);
Line 1613:        
Line 1614:


Source File: c:\src\StudyTimeTrackerPrimeI\Default.aspx.cs    Line: 1612

Stack Trace:

[COMException (0x80040213): The transport failed to connect to the server.
]

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
   System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) +337
   System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture) +36
   System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object obj, String methodName, Object[] args) +66
   System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +49

[HttpException (0x80004005): The transport failed to connect to the server.
]
   System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +99
   System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1738
   System.Web.Mail.SmtpMail.Send(MailMessage message) +273
   _Default.StudentSignInOut() in c:\src\StudyTimeTrackerPrimeI\Default.aspx.cs:1612
   _Default.btnSignIn_click(Object sender, EventArgs e) in c:\src\StudyTimeTrackerPrimeI\Default.aspx.cs:1540
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


Version Information: Microsoft .NET Framework Version:2.0.50727.5446; ASP.NET Version:2.0.50727.5420

Open in new window

0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
thanks for your help
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now