Showing posts with label sending. Show all posts
Showing posts with label sending. Show all posts

Tuesday, March 13, 2012

stuck on empty page after sending email with.........mailto:"email address here"

Hi, i have code that opens an Ms outlook new email message window on myGridviews' ItemUpdated event. I did this because of the easy with which users will find email addresses to send messages to with out the pain of remembering or cramming the so many company employee email accounts. After sending the email, outlook closes which is okay to me but the problem is, i now remain with a blank page instead of returning to the page with my Gridview from where i fired the update event that opened outlook. I wish i had away of posting or redirecting to another page or even better returning to the same page from ItemUpdated event that opened outlook was fired from. Iam not sure if this explaination is clear to any one reading it but below is the code iam talking about.

ProtectedSub GridView1_RowUpdated(ByVal senderAsObject,ByVal eAs System.Web.UI.WebControls.GridViewUpdatedEventArgs

Response.Redirect(mailto:my-email-account@dotnet.itags.org.ppp.co.ug

Response.redirect("Default.aspx") 'Why is this line of code not redirecting to Default.aspx

END SUb

Option Two: How can i open outlook when an event fires without using Response.Redirect because that is exactly what what is bringing me all this mess.

Dont use a Response.Redirect(), just use an HREF...


Your first response.redirect changes the page you are on, so the second one never fires.

Why not just show the email address when your user updates the row? Or use a pop-up to display the email address for the user to click.

Try creating a hidden iframe and setting the location of the iframe to the mailto address. This might do the trick, but I haven't tested it.

--JJ


This is my scenerio. when a row is updated, basically we are talking about a name field which is initially null being filled with an employee name. So when the user clicks update after typing the employee name in this field, On the itemUpdate event of this particular Gridview, outlook opens and then the administrator doing the update should lookup the email address in outlook of the same employee whose name was entererd prevously. The aim is to send a notification email that he has been assigned a record he/she should take charge of.

So at the end of the operation, a record should have been updated and an outlook email(not automatic) should have been send to the employee whose name was entered in the Gridviews' name field.


How do you use HREF in an event handle sub procedure.


By HREF, Curt means a HyperLink. You need to use a hyperlink and open a popup to send the mail

<a href="http://links.10026.com/?link=my-email-account@.ppp.co.ug" target="_blank">Send Mail</a>

Thanks

Stuck with sending emails

I've been wrestling on my own trying to send email from an asp.net page, but I'm having no luck at all :(

<%@dotnet.itags.org. Page Language="vb" %>
<%@dotnet.itags.org. Register TagPrefix="nav" TagName="bar" src="http://pics.10026.com/?src=navigation.ascx" %>
<%@dotnet.itags.org. Import Namespace="System.Web.Mail" %
<script language="vb" debug="true"
Sub btnGo_Click(sender As Object, e As EventArgs)

LabelSent.text = "about to try sending mail"

Dim from as String = "neil@dotnet.itags.org.domain.com";
Dim to as String = "neil@dotnet.itags.org.domain.com";
Dim subject as String = "subject text";
Dim Body as String = "body text";
Dim from as String = "neil@dotnet.itags.org.domain.com";

sendMail(to, from, subject, Body, false, "mail.domain.com")

End Sub

Public Function SendMail(ByVal [To] As String, _
ByVal From As String, ByVal Subject As String, _
ByVal Body As String, ByVal IsHTML As Boolean, _
Optional ByVal SmtpServer As String = "mail.yuzumedia.com") As Boolean
' Sends a mail message using the specified details
' - returns a False if delivery fails

Try
Dim objMsg As New System.Web.Mail.MailMessage()
SendMail = True
With objMsg
.To = [To]
.From = From
.Subject = Subject
.Body = Body
' .BodyFormat specifies whether the Body is
' in plain text or HTML format
.BodyFormat = IIf(IsHTML = True, _
System.Web.Mail.MailFormat.Html, _
System.Web.Mail.MailFormat.Text)
End With
System.Web.Mail.SmtpMail.SmtpServer = SmtpServer
System.Web.Mail.SmtpMail.Send(objMsg)
Catch
SendMail = False
End Try
End Function

</script

-->the button


<asp:Button ID="btnGo" Text="Go!" CommandName="btnGo_Click" runat="server" />
You can specify an event handler for the button:

<asp:Button ID="btnGo" Text="Go!" OnClick="btnGo_Click" runat="server" /
FYI:http://asp.net/webmatrix/guidedtour/section13/createemailform.aspx

Regards,
thanks,

I just got this instead:


Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'btnGo_Click' is not a member of 'ASP.enquiry4_aspx'.

I'm still getting that error, I've not had time to follow the tutorial there properly, but can someone tell me what I'm doing to get that compilation error?
I think (and I could be talking out my ass here) that you need a Handles statement for the click event:

Sub btnGo_Click(sender As Object, e As EventArgs)Handles btnGo.Click
just tried that now,

unfortunately it makes no difference, it still just gives me the following msg

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'btnGo_Click' is not a member of 'ASP.enquiry4_aspx'.
Can you post the relevant code again?
If you are using VS.NET go to design view and double click your button.

It will create method to handle click event of your button. Just type your code in, recompile your project and it should work.
Its pretty much the same as before except forHandles btnGo.Click

<%@. Page Language="vb" %>
<%@. Register TagPrefix="nav" TagName="bar" src="http://pics.10026.com/?src=navigation.ascx" %>
<%@. Import Namespace="System.Web.Mail" %
<script language="vb" debug="true"
Sub btnGo_Click(sender As Object, e As EventArgs) Handles btnGo.Click

Dim from as String = "neil@.mydomain.com";
Dim to as String = "neil@.mydomain.com";
Dim subject as String = "subject text";
Dim Body as String = "body text";
Dim from as String = "neil@.mydomain.com";

sendMail(to, from, subject, Body, false, "mail.mydomain.com")

End Sub

Public Function SendMail(ByVal [To] As String, _
ByVal From As String, ByVal Subject As String, _
ByVal Body As String, ByVal IsHTML As Boolean, _
Optional ByVal SmtpServer As String = "mail.mydomain.com") As Boolean
' Sends a mail message using the specified details
' - returns a False if delivery fails

Try
Dim objMsg As New System.Web.Mail.MailMessage()
SendMail = True
With objMsg
.To = [To]
.From = From
.Subject = Subject
.Body = Body
' .BodyFormat specifies whether the Body is
' in plain text or HTML format
.BodyFormat = IIf(IsHTML = True, _
System.Web.Mail.MailFormat.Html, _
System.Web.Mail.MailFormat.Text)
End With
System.Web.Mail.SmtpMail.SmtpServer = SmtpServer
System.Web.Mail.SmtpMail.Send(objMsg)
Catch
SendMail = False
End Try
End Function

</script
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML xmlns:o xmlns:st1>
<HEAD>
<title>Milano - Contact</title>
<link href="http://links.10026.com/?link=milano.css" rel="stylesheet" type="text/css">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></HEAD>
<BODY bgColor="#ffffff" MS_POSITIONING="GridLayout">
<form id="Gallery" method="post" runat="server" action="mailto:neil@.mydomain.com">
<TABLE cellSpacing="0" cellPadding="0" width="691" align="center" border="0">
<TR>
<TD colspan="3">
<div align="right"><nav:bar id=myBar runat=server />
</div></TD>
</TR>
<TR>
<TD style="HEIGHT: 15px" colSpan="2"> </TD>
</TR>
<TR>
<TD colSpan="3"><IMG height="169" alt="" src="http://pics.10026.com/?src=images/studio_mainbar.jpg" width="691"></TD>
</TR>
<TR>
<TD colSpan="3"><IMG height="10" alt="" src="http://pics.10026.com/?src=images/pixel.gif" width="691"></TD>
</TR>
<TR>
<TD colSpan="3"><IMG height="23" alt="" src="http://pics.10026.com/?src=images/contact_bar.gif" width="691"></TD>
</TR>
<TR>
<TD colSpan="3"><IMG height="10" alt="" src="http://pics.10026.com/?src=images/pixel.gif" width="691"></TD>
</TR>
<TR>
<TD colSpan="3">
<table id="page_content" cellPadding="10" width="100%" border="0">
<tr>
<td style="WIDTH: 349px" vAlign="top" align="left" colSpan="2" rowSpan="2" width="349"
class="maintext">
<div align="left" class="maintext">
<p>Please
email any enquiries to enquiries@.studioglasgow.co.uk</p>
<p>Phone - 0141 332 1444</p>
<p>STUDIO - 98 Sauchiehall Street -
Glasgow</p>
</div> </td>
<TD vAlign="top" align="center" width="323" colSpan="2"><P class="MsoNormal">
</P>
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><span class="MsoNormal">
<asp:Label ID="Label1" runat="server" CssClass="maintext">name</asp:Label>
</span></td>
<td><span class="MsoNormal">
<asp:TextBox ID="TextBoxName" runat="server"></asp:TextBox>
</span></td>
</tr>
<tr>
<td><span class="MsoNormal">
<asp:Label ID="Label2" runat="server" CssClass="maintext">tel</asp:Label>
</span></td>
<td><span class="MsoNormal">
<asp:TextBox ID="TextBoxTel" runat="server"></asp:TextBox>
</span></td>
</tr>
<tr>
<td><span class="MsoNormal">
<asp:Label ID="Label3" runat="server" CssClass="maintext">email</asp:Label>
</span></td>
<td><span class="MsoNormal">
<asp:TextBox ID="TextBoxEmail" runat="server"></asp:TextBox>
</span></td>
</tr>
<tr>
<td><span class="MsoNormal">
<asp:Label ID="Label4" runat="server"
CssClass="maintext">address</asp:Label>
</span></td>
<td><span class="MsoNormal">
<asp:TextBox ID="TextBoxAddress" runat="server" Height="56px" TextMode="MultiLine"></asp:TextBox>
</span></td>
</tr>
<tr>
<td><span class="MsoNormal">
<asp:Label ID="Label5" runat="server"
CssClass="maintext">enquiry</asp:Label>
</span></td>
<td><span class="MsoNormal">
<asp:TextBox ID="TextBoxEnquiry" runat="server" Width="290" Height="152px" TextMode="MultiLine"></asp:TextBox>
</span></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit">
<asp:Button ID="btnGo" Text="Go!" OnClick="btnGo_Click" CommandName="btnGo_Click" runat="server" /></td>
</tr>
</table>
</TD>
</tr>
</table>
</TD>
</TR>
<TR>
<TD><IMG height="1" alt="" src="http://pics.10026.com/?src=images/pixel.gif" width="316"></TD>
<TD style="WIDTH: 120px"><IMG height="1" alt="" src="http://pics.10026.com/?src=images/pixel.gif" width="196"></TD>
<TD><IMG height="1" alt="" src="http://pics.10026.com/?src=images/pixel.gif" width="179"></TD>
</TR>
</TABLE>
</form>
</BODY>
</HTML


I've not got VS studio,

got webmatrix though, but have hardly used it, will that do the same?
Hey, the only problem I could find was that the BtnGo_Click method itself is a little weird. Semi colons at the end of lines? Double declaration of from? Keywords used as variable names ('To' for example, which is why it's in [] in the function call, but I don't believe this is valid in VB).

I use VS, so all of these problems were caught before building, but I know nothing about WebMatrix. My BtnGo event:


Sub btnGo_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnGo.Click
Dim sfrom As String = "neil@.mydomain.com"
Dim sto As String = "neil@.mydomain.com"
Dim ssubject As String = "subject text"
Dim sBody As String = "body text"

SendMail(sto, sfrom, ssubject, sBody, False, "mail.mydomain.com")
End Sub


I'm not having much luck with this either.....

<b>
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30188: Declaration expected.

Source Error:

Line 7: 'create new email msg
Line 8: Dim newMail As new MailMessage
Line 9: newMail.From = "neil@.mydomain.com"
Line 10: newMail.To = "neil@.mydomain.com"
Line 11: newMail.Subject = "myMail"

Source File: c:\inetpub\wwwroot\milanos\myMail.aspx Line: 9

<b/


<%@. Import Namespace="system.Web.Mail" %>
<html>
<head>
<script language="vb" runat="server"
'create new email msg
Dim newMail As new MailMessage
newMail.From = "neil@.mydomain.com"
newMail.To = "neil@.mydomain.com"
newMail.Subject = "myMail"
newMail.Body = "myMail :: body"

SmtpMail.Send(newMail)
End Sub

</script
<title>Untitled Document</title>
</head>
<body
</body>
</html


@.colt

i followed the steps in the guide and its all kosher now :)