|
|
can i send the email through the localhost, i mean through my machine directly ?
I have installed SMTP Virtual Servers in IIS 6.0, through the XP CD !
|
|
|
|
|
I think no but you can verify it whether are you able to send or not.
provide the SMTP server name is 172.0.0.1.
Send mail through the code and check on below location you will found there some file. Open it into the notepad.
C:\Inetpub\mailroot\Queue
Parwej Ahamad
R & D: REST services with WCF
|
|
|
|
|
it is giving
SmtpException<br />
Failure sending mail.
what shall I do ?
|
|
|
|
|
Where you are providing the SMTP Server name in Web.config file ?
IF Yes then examine like this:
<system.net>
<mailsettings>
<smtp from="test@par.com">
<network host="172.0.0.1 OR localhost" port="25" username="" password="" defaultcredentials="true" />
</smtp>
</mailsettings>
</system.net>
OR try external SMTP Server of Gmail
System.Net.Mail.SmtpClient email = new System.Net.Mail.SmtpClient();
email.Host = "smtp.gmail.com";
email.Port = 465 ;
............
............
Parwej Ahamad
R & D: REST services with WCF
|
|
|
|
|
again SmtpException
this time
The operation has timed out.
|
|
|
|
|
|
Parwej Ahamad wrote: which one you are using ?
anti-virus ?
avg free !
|
|
|
|
|
are you set on web.config file or using the Google SMTP server ?
Parwej Ahamad
R & D: REST services with WCF
|
|
|
|
|
|
|
Parwej Ahamad wrote: Are you logged on any IM ?
-> na...
code:
protected void Page_Load(object sender, EventArgs e)
{
string server;
server = "localhost";
string file = "data.xls";
file = Server.MapPath("~/data.xls");
MailMessage message = new MailMessage(
"apurvkolte@live.com",
"apurvkolte@gmail.com",
"Quarterly data report.",
"See the attached spreadsheet.");
Attachment data = new Attachment(file, MediaTypeNames.Application.Octet);
ContentDisposition disposition = data.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(file);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
message.Attachments.Add(data);
SmtpClient client = new SmtpClient();
client.Host = "smtp.gmail.com";
client.Port = 465;
client.Credentials = CredentialCache.DefaultNetworkCredentials;
client.Send(message);
ContentDisposition cd = data.ContentDisposition;
Console.WriteLine("Content disposition");
Console.WriteLine(cd.ToString());
Console.WriteLine("File {0}", cd.FileName);
Console.WriteLine("Size {0}", cd.Size);
Console.WriteLine("Creation {0}", cd.CreationDate);
Console.WriteLine("Modification {0}", cd.ModificationDate);
Console.WriteLine("Read {0}", cd.ReadDate);
Console.WriteLine("Inline {0}", cd.Inline);
Console.WriteLine("Parameters: {0}", cd.Parameters.Count);
foreach (DictionaryEntry d in cd.Parameters)
{
Console.WriteLine("{0} = {1}", d.Key, d.Value);
}
data.Dispose();
}
|
|
|
|
|
i have copied it from msdn
|
|
|
|
|
Let me check on my machine ?
Parwej Ahamad
R & D: REST services with WCF
|
|
|
|
|
i am going to sleep now.
we'll talk tomorrow ...
bye
gn
|
|
|
|
|
Below given code are working fine on my machine.
Note: Which I have mark as bold provide there your gmail id and password.
MailMessage MyMailMessage=new MailMessage();
MyMailMessage.From = new MailAddress("g.parwez@gmail.com");
MyMailMessage.To.Add("g.parwez@gmail.com");
MyMailMessage.Subject = "Parwej Testing !!!";
MyMailMessage.Body = "This is the test text for Parwej Ahamad";
SmtpClient SMTPServer=new SmtpClient("smtp.gmail.com");
SMTPServer.Port = 587;
SMTPServer.Credentials =new System.Net.NetworkCredential("yourgmaid", "yourgmailpassword");
SMTPServer.EnableSsl = true;
SMTPServer.Send(MyMailMessage);
After that you can check your attachment code.
Parwej Ahamad
R & D: REST services with WCF
|
|
|
|
|
I am trying to read a sql database so the same rows will not be inserted. I already got the connection I just need to know how to not insert the same row twice. I am using the VB language. Any ideas?
|
|
|
|
|
jds1207 wrote: so the same rows will not be inserted
so u don`t wan`t to insert anything...
jds1207 wrote: I just need to know how to not insert the same row twice
But now you are saying u need to insert it twice....
Pls be a bit more clear every time u post a question, otherwise u ll keep howling like a donkey...
|
|
|
|
|
This is how I am trying to get it. For example, If I insert a row into the database that have a department name HR and a username user.name and I try to insert another row that has the same department and username, the new row can't be inserted because the department and username already exists.
|
|
|
|
|
You could first select the record you are trying to insert. If you get something back, then you know it already exists.
I would also recommend that you research using a DataAdapter object which, if setup correctly, can help a lot with inserting, updating, deleting, etc. You could start your research with some of these articles.[^]
Hope this helps.
|
|
|
|
|
Read up on unique constraints.
Generally your database shouldn't let you insert "bad" data, so you enforce this with constraints. Then your UI probably should deal with the situation nicely, either by checking first, or handling the exception that gets thrown when you try to insert the second row.
|
|
|
|
|
--------------------------------------------------------------------------------
I have an 'edit' button in each row created by my repeater. The problem I'm having is none of the controls I have in my ItemTemplate will save their state.
Everything I've read said that controls listed in the template will automatically remember their view state. I can't even seem to get them to remember their state from one function to the next. Does DataBind() somehow wipe their state? Also, on a postback, why does the repeater call Repeater1_ItemCreated() twice for each item?
I've made a really simple test app and it still doesn't work. What do I need to do to get this to work? In this app I'm simply trying to get each row to remember if they are in edit mode.
Thanks,
RepeaterEditModeTest.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="RepeaterEditModeTest.aspx.vb" Inherits="HR_RepeaterEditModeTest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td id="rowItemRow" runat="server"></td>
<td>
<asp:LinkButton ID="cmdEdit" CommandName="Edit" runat="server">Edit</asp:LinkButton>
<asp:LinkButton ID="cmdSave" CommandName="Save" runat="server">Save</asp:LinkButton>
<asp:LinkButton ID="cmdCancel" CommandName="Cancel" runat="server">Cancel</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
RepeaterEditModeTest.aspx.vb
Option Explicit On
Option Strict On
Imports System.Collections.Generic
Partial Class HR_RepeaterEditModeTest
Inherits System.Web.UI.Page
Public Data As New SortedList(Of String, Boolean)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Data.Add("ABC", False)
Data.Add("DEF", False)
Data.Add("GHI", False)
Data.Add("JKL", False)
Repeater1.DataSource = Data
Repeater1.DataBind()
End Sub
Protected Sub Repeater1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemCreated
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim cmdEdit As LinkButton = CType(e.Item.FindControl("cmdEdit"), LinkButton)
Dim cmdSave As LinkButton = CType(e.Item.FindControl("cmdSave"), LinkButton)
Dim cmdCancel As LinkButton = CType(e.Item.FindControl("cmdCancel"), LinkButton)
Dim kvp As KeyValuePair(Of String, Boolean) = CType(e.Item.DataItem, KeyValuePair(Of String, Boolean))
cmdEdit.CommandArgument = kvp.Key
cmdSave.CommandArgument = kvp.Key
cmdCancel.CommandArgument = kvp.Key
' this will only be true for one item and it'll be for the one clicked
Dim editMode As Boolean = kvp.Value
' this will get the other ones that are in edit mode
If cmdEdit.Attributes("EditMode") Is Nothing = False Then
If cmdEdit.Attributes("EditMode") = "Y" Then
editMode = True
End If
End If
' Adjust visibility of edit/save/cancel to reflect mode
If editMode Then
cmdEdit.Visible = False
cmdSave.Visible = True
cmdCancel.Visible = True
Else
cmdEdit.Visible = True
cmdSave.Visible = False
cmdCancel.Visible = False
End If
End If
End Sub
Protected Sub Repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Repeater1.ItemCommand
Dim cmdEdit As LinkButton = CType(e.Item.FindControl("cmdEdit"), LinkButton)
If e.CommandName = "Edit" Then
Data(CStr(e.CommandArgument)) = True
cmdEdit.Attributes("EditMode") = "Y"
ElseIf e.CommandName = "Save" Then
Data(CStr(e.CommandArgument)) = False
cmdEdit.Attributes("EditMode") = "N"
ElseIf e.CommandName = "Cancel" Then
Data(CStr(e.CommandArgument)) = False
cmdEdit.Attributes("EditMode") = "N"
End If
Repeater1.DataSource = Data
Repeater1.DataBind()
End Sub
End Class
|
|
|
|
|
Hi all,
My site got hit with SQL injection attack, and I'm now looking for ways to ensure that this won't happen again.
Actually I thought I was pretty well covered against SQL injection attacks, but apparently I was wrong. One technique I've been using is when I pass ID's through querystring is to do something like this:
String strID = Request.QueryString["ID"];
if ( !String.IsNullOrEmpty( strID ) )
{
int nID = Convert.ToInt32( strID );
myDBWrapper.GetSomeData( nID );
}
public MyDataCollection GetSomeData( int nID )
{
String strSQL = String.Format( "SELECT * FROM MyData WHERE ID = {0}", nID );
}
Would you consider this code to be vulnerable? I'm aware of SQL parameters, and I use them in other circumstances, such as when inserting into tables. But I've always believed that it wasn't necessary in these situations, because the conversion to Int32 would fail if the Query String parameter did contain some malicious SQL statments.
Any comments?
Regards,
Daníel
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
This is my take on an injection attack
If you have a textbox which a user can enter data into and that textbox value is then used in a query which is written into your c# code (i.e. not a stored procedure) then you are at risk of attack unless you can filter their input.
To answer your question I'm not sure if the above code would be vunerable but my using the above methodology you might be able to work it out yourself
hope this helps
We are not a Code Charity
|
|
|
|
|
Yes, I'm using command parameters for all values which the user can enter.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|