Saturday, March 31, 2012
System.FormatException
When I trying to execute this code,
insGrupo = Nothing
insGrupo = New Grupo(Short.Parse(0), TxtGrCoCodi.Text)
occurs the following error
System.FormatException: Sequence of entrance was not in a incorrect format.
Somebody knows what it can be this error?
---------------
Marcus Vincius M. Montezanodid you get help with this?
--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Marcus Vincius" <marc.marcus@.bol.com.br> wrote in message
news:%23M9qgFe1DHA.4032@.tk2msftngp13.phx.gbl...
> Hi Guys,
> When I trying to execute this code,
> insGrupo = Nothing
> insGrupo = New Grupo(Short.Parse(0), TxtGrCoCodi.Text)
>
> occurs the following error
> System.FormatException: Sequence of entrance was not in a incorrect
format.
>
> Somebody knows what it can be this error?
>
> ---------------
> Marcus Vincius M. Montezano
System.IndexOutOfRangeException
Public Sub SelectPieceByProductID()
Try
Dim arParams(0) As SqlParameter
arParams(0) = New SqlParameter("@dotnet.itags.org.lProductID", lProductID)
Dim oDR As SqlDataReader =
oData.ExecuteReader(sConnectionString, CommandType.StoredProcedure,
"spSelectPieceByProductID", arParams)
If oDR.HasRows Then
Do While oDR.Read()
sPieceNumber = CType(oDR.Item("PieceNumber"),
String)
lMetalID = CType(oDR.Item("MetalID"), Long)
lTotalCount = CType(oDR.Item("TotalCount"), Long)
dTotalWeight = CType(oDR.Item("TotalWeight"),
Double)
--> lNonCenterCount =
CType(oDR.Item("NonCenterCount "), Long)
dNonCenterWeight =
CType(oDR.Item("NonCenterWeight"), Double)
dPrice = CType(oDR.Item("Price"), Double)
lMarkup = CType(oDR.Item("Markup"), Long)
bActive = CType(oDR.Item("Active"), Boolean)
bDeleted = CType(oDR.Item("Deleted"), Boolean)
Loop
End If
oDR.Close()
oDR = Nothing
oData = Nothing
Catch ex As Exception
End Try
End Sub
I am getting an "System.IndexOutOfRangeException" exception on the
marked line. All values prior to this line are being set correctly.
Anyone see the issue here? I run the query in query analyzer with the
appropriate id and it works fine.
I'm clueless.
Thanks.It seems that the NonCenterCount column does not exist. Perhaps the column
name is mispelled either here, or in the table definition.
"Ratman" <jake@.attis.org> wrote in message
news:df331d52.0406210944.2c966e3c@.posting.google.c om...
> I have the following code...
> Public Sub SelectPieceByProductID()
> Try
> Dim arParams(0) As SqlParameter
> arParams(0) = New SqlParameter("@.lProductID", lProductID)
> Dim oDR As SqlDataReader =
> oData.ExecuteReader(sConnectionString, CommandType.StoredProcedure,
> "spSelectPieceByProductID", arParams)
> If oDR.HasRows Then
> Do While oDR.Read()
> sPieceNumber = CType(oDR.Item("PieceNumber"),
> String)
> lMetalID = CType(oDR.Item("MetalID"), Long)
> lTotalCount = CType(oDR.Item("TotalCount"), Long)
> dTotalWeight = CType(oDR.Item("TotalWeight"),
> Double)
> --> lNonCenterCount =
> CType(oDR.Item("NonCenterCount "), Long)
> dNonCenterWeight =
> CType(oDR.Item("NonCenterWeight"), Double)
> dPrice = CType(oDR.Item("Price"), Double)
> lMarkup = CType(oDR.Item("Markup"), Long)
> bActive = CType(oDR.Item("Active"), Boolean)
> bDeleted = CType(oDR.Item("Deleted"), Boolean)
> Loop
> End If
> oDR.Close()
> oDR = Nothing
> oData = Nothing
> Catch ex As Exception
> End Try
> End Sub
> I am getting an "System.IndexOutOfRangeException" exception on the
> marked line. All values prior to this line are being set correctly.
> Anyone see the issue here? I run the query in query analyzer with the
> appropriate id and it works fine.
> I'm clueless.
> Thanks.
System.IndexOutOfRangeException
Public Sub SelectPieceByProductID()
Try
Dim arParams(0) As SqlParameter
arParams(0) = New SqlParameter("@dotnet.itags.org.lProductID", lProductID)
Dim oDR As SqlDataReader =
oData.ExecuteReader(sConnectionString, CommandType.StoredProcedure,
"spSelectPieceByProductID", arParams)
If oDR.HasRows Then
Do While oDR.Read()
sPieceNumber = CType(oDR.Item("PieceNumber"),
String)
lMetalID = CType(oDR.Item("MetalID"), Long)
lTotalCount = CType(oDR.Item("TotalCount"), Long)
dTotalWeight = CType(oDR.Item("TotalWeight"),
Double)
--> lNonCenterCount =
CType(oDR.Item("NonCenterCount "), Long)
dNonCenterWeight =
CType(oDR.Item("NonCenterWeight"), Double)
dPrice = CType(oDR.Item("Price"), Double)
lMarkup = CType(oDR.Item("Markup"), Long)
bActive = CType(oDR.Item("Active"), Boolean)
bDeleted = CType(oDR.Item("Deleted"), Boolean)
Loop
End If
oDR.Close()
oDR = Nothing
oData = Nothing
Catch ex As Exception
End Try
End Sub
I am getting an "System.IndexOutOfRangeException" exception on the
marked line. All values prior to this line are being set correctly.
Anyone see the issue here? I run the query in query analyzer with the
appropriate id and it works fine.
I'm clueless.
Thanks.It seems that the NonCenterCount column does not exist. Perhaps the column
name is mispelled either here, or in the table definition.
"Ratman" <jake@.attis.org> wrote in message
news:df331d52.0406210944.2c966e3c@.posting.google.com...
> I have the following code...
> Public Sub SelectPieceByProductID()
> Try
> Dim arParams(0) As SqlParameter
> arParams(0) = New SqlParameter("@.lProductID", lProductID)
> Dim oDR As SqlDataReader =
> oData.ExecuteReader(sConnectionString, CommandType.StoredProcedure,
> "spSelectPieceByProductID", arParams)
> If oDR.HasRows Then
> Do While oDR.Read()
> sPieceNumber = CType(oDR.Item("PieceNumber"),
> String)
> lMetalID = CType(oDR.Item("MetalID"), Long)
> lTotalCount = CType(oDR.Item("TotalCount"), Long)
> dTotalWeight = CType(oDR.Item("TotalWeight"),
> Double)
> --> lNonCenterCount =
> CType(oDR.Item("NonCenterCount "), Long)
> dNonCenterWeight =
> CType(oDR.Item("NonCenterWeight"), Double)
> dPrice = CType(oDR.Item("Price"), Double)
> lMarkup = CType(oDR.Item("Markup"), Long)
> bActive = CType(oDR.Item("Active"), Boolean)
> bDeleted = CType(oDR.Item("Deleted"), Boolean)
> Loop
> End If
> oDR.Close()
> oDR = Nothing
> oData = Nothing
> Catch ex As Exception
> End Try
> End Sub
> I am getting an "System.IndexOutOfRangeException" exception on the
> marked line. All values prior to this line are being set correctly.
> Anyone see the issue here? I run the query in query analyzer with the
> appropriate id and it works fine.
> I'm clueless.
> Thanks.
System.IndexOutOfRangeException
I have the following code where all the used variable are declared to their respective types:
insertSql = "SELECT Max([Customer ID]) AS CustID FROM [Registration Info]"
objCommand = New OleDbCommand(insertSql, objConn)
objConn.Open()
objDR = objCommand.ExecuteReader()
While objDR.Read()
CustID=objDR("Cust ID") '********** (1.)
End While
I am getting an error on (1.). its says "System.IndexOutOfRangeException: Cust ID" why is this happening? Can comeone help me whith this problem?
Thanks,
~sIf the code enters the while loop then tere are values within objDR so why not add a watch to this and check the value of objDr(0) and then objDR(1)
Hope that helps
Cheers
Gregor Suttie
I would say it is happening because there is no field in the result called "Cust ID", though there is one called "CustID"
Yes i know thats a silly mistake on my part. very silly... i wish i could delete this post. :) thanks very much. now i am doing it like objDR(0)
Regards.
System.IndexOutOfRangeException: Index was outside the bounds of the array
Hi i am getting the following error "System.IndexOutOfRangeException: Index was outside the bounds of the array". it is coming from this line of code ;
Line 595: // Build Column Name PartLine 596: strPart1 = strPart1 + "`" + strData[lngIter, 0] + "`,";Line 597:
It may have been caused by the following code;
staticpublicstring buildQuery(string strAction,string strTableName,string[,] strData,string[,] strWhere,string strWhereOverride,string strLimit,string strOffset,string strOrderBy){
// Array Definitions
//strData(x,0)=ColumnName
//strData(x,1)=ColumnData
You will get this if you use an index that is higher than the number of items in the array. So check if the lngIter is within the index range of the array so you don't pass an index which is higher than the total amount of items in the array.
Hi, i am quite new to programming, so i am unsure if i have declared the arrays properly, however i will show you some code and if you could tell me if you can identify where i have to declare the array.;
The following code is in the page calling up a method;
clsOBJ objDHOC =newclsOBJ();Pmillio.clsOBJ.buildQuery("INSERT","tblProperty", strData, strWhere,"","1","1","strData");
string[,] strData =newstring[11, 2];string[,] strWhere =newstring[11, 3];
strData[0, 0] ="StatutoryDate";strData[0, 1] = txtDate.Text;
The following code is what in the DAL which the one above is referencing;
staticpublicstring buildQuery(string strAction,string strTableName,string[,] strData,string[,] strWhere,string strWhereOverride,string strLimit,string strOffset,string strOrderBy){
// Array Definitions
//strData(x,0)=ColumnName
//strData(x,1)=ColumnData
// Ucase
strAction = (strAction);
// Dimension
string strSQL;int lngIter;
string strPart1 =null;string strPart2 =null;
System.InvalidCastException:
I get a System.InvalidCastException on the following code.
ObjtInterestLadder.dblPrinCcyAmt = (double) dsRecs.Tables["DetailData"].Rows[iSub]["Prin_Ccy_Amt"];
Why is this.
When I retrieve the data to a string it is OK
sData = (string) dsRecs.Tables["DetailData"].Rows[iSub]["Prin_Ccy_Amt"].ToString();
have you checked for NULL values?
franklb wrote:
Why is this.
When I retrieve the data to a string it is OK
sData = (string) dsRecs.Tables["DetailData"].Rows[iSub]["Prin_Ccy_Amt"].ToString();
What is it showing when you do that ? If it is null or blank it will show exception.
System.InvalidCastException: Specified cast is not valid.
I get the this error when i run my code:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
this.DataGrid1.DataSource= this.DataSource();
this.DataGrid1.DataBind();
}
private ICollection DataSource()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("kol0",typeof(Int16)));
for (int i=0;i<10;i++)
{
DataRow dr = dt.NewRow();
if (i%2==0)
{
dr[0]=1;
}
else
{
dr[0]=0;
}
dt.Rows.Add(dr);
}
DataView dv;
dv = new DataView(dt);
return dv;
}
private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
int i = e.Item.ItemIndex;
if(i==0)
{
((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
}
}
page:
one two
one two
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
absolute; TOP: 56px" runat="server"
Height="216px" Width="448px" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:DropDownList ID="dll" Runat="server">
<asp:ListItem Value="0">one</asp:ListItem>
<asp:ListItem Value="1">two</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
ch JIt would help if you told us the line #. Is it at:
((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
First of all, it looks like you are doing that when ItemIndex == 0
wouldn't that be ur HeaderTemplate in which case cell[0].Controls[0]. really
might not be what you expect. Secondly, you might prefer
e.Item.FindControl("dll") or e.Item.Cells[0].FindContorl("dll") (not sure
which will work, favor the first one if it'll work) over using indexes. It
makes your code more flexible and less likely to break. Sometimes literals
(like spaces and newlines) are converted to controls, so while you might
think it's Controls[0], it might really be Controls[1] 'cuz there was a
newline before it.
It should be pretty easy to step through your code and debug though...
Karl
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
"Jimmy" <beffer@.gmail.com> wrote in message
news:eX0b2r$yFHA.2556@.TK2MSFTNGP10.phx.gbl...
> Hi
> I get the this error when i run my code:
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> this.DataGrid1.DataSource= this.DataSource();
> this.DataGrid1.DataBind();
> }
> private ICollection DataSource()
> {
> DataTable dt = new DataTable();
>
> dt.Columns.Add(new DataColumn("kol0",typeof(Int16)));
>
> for (int i=0;i<10;i++)
> {
> DataRow dr = dt.NewRow();
> if (i%2==0)
> {
> dr[0]=1;
>
> }
> else
> {
> dr[0]=0;
>
> }
> dt.Rows.Add(dr);
> }
> DataView dv;
> dv = new DataView(dt);
> return dv;
> }
> private void DataGrid1_ItemDataBound(object sender,
> System.Web.UI.WebControls.DataGridItemEventArgs e)
> {
> int i = e.Item.ItemIndex;
> if(i==0)
> {
> ((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
> }
>
> }
>
> page:
>
> one two
> one two
> <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
> absolute; TOP: 56px" runat="server"
> Height="216px" Width="448px" AutoGenerateColumns="False">
> <Columns>
> <asp:TemplateColumn>
> <ItemTemplate>
> <asp:DropDownList ID="dll" Runat="server">
> <asp:ListItem Value="0">one</asp:ListItem>
> <asp:ListItem Value="1">two</asp:ListItem>
> </asp:DropDownList>
> </ItemTemplate>
> </asp:TemplateColumn>
> </Columns>
> </asp:DataGrid>
> ch J
>
>
>
System.InvalidCastException: Specified cast is not valid.
I get the this error when i run my code:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
this.DataGrid1.DataSource= this.DataSource();
this.DataGrid1.DataBind();
}
private ICollection DataSource()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("kol0",typeof(Int16)));
for (int i=0;i<10;i++)
{
DataRow dr = dt.NewRow();
if (i%2==0)
{
dr[0]=1;
}
else
{
dr[0]=0;
}
dt.Rows.Add(dr);
}
DataView dv;
dv = new DataView(dt);
return dv;
}
private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
int i = e.Item.ItemIndex;
if(i==0)
{
((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
}
}
page:
one two
one two
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
absolute; TOP: 56px" runat="server"
Height="216px" Width="448px" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:DropDownList ID="dll" Runat="server">
<asp:ListItem Value="0">one</asp:ListItem>
<asp:ListItem Value="1">two</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid
ch JIt would help if you told us the line #. Is it at:
((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
First of all, it looks like you are doing that when ItemIndex == 0
wouldn't that be ur HeaderTemplate in which case cell[0].Controls[0]. really
might not be what you expect. Secondly, you might prefer
e.Item.FindControl("dll") or e.Item.Cells[0].FindContorl("dll") (not sure
which will work, favor the first one if it'll work) over using indexes. It
makes your code more flexible and less likely to break. Sometimes literals
(like spaces and newlines) are converted to controls, so while you might
think it's Controls[0], it might really be Controls[1] 'cuz there was a
newline before it.
It should be pretty easy to step through your code and debug though...
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
"Jimmy" <beffer@.gmail.com> wrote in message
news:eX0b2r$yFHA.2556@.TK2MSFTNGP10.phx.gbl...
> Hi
> I get the this error when i run my code:
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> this.DataGrid1.DataSource= this.DataSource();
> this.DataGrid1.DataBind();
> }
> private ICollection DataSource()
> {
> DataTable dt = new DataTable();
>
> dt.Columns.Add(new DataColumn("kol0",typeof(Int16)));
>
> for (int i=0;i<10;i++)
> {
> DataRow dr = dt.NewRow();
> if (i%2==0)
> {
> dr[0]=1;
>
> }
> else
> {
> dr[0]=0;
>
> }
> dt.Rows.Add(dr);
> }
> DataView dv;
> dv = new DataView(dt);
> return dv;
> }
> private void DataGrid1_ItemDataBound(object sender,
> System.Web.UI.WebControls.DataGridItemEventArgs e)
> {
> int i = e.Item.ItemIndex;
> if(i==0)
> {
> ((DropDownList)e.Item.Cells[0].Controls[0]).SelectedValue="one";
> }
>
> }
>
> page:
>
> one two
> one two
> <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
> absolute; TOP: 56px" runat="server"
> Height="216px" Width="448px" AutoGenerateColumns="False">
> <Columns>
> <asp:TemplateColumn>
> <ItemTemplate>
> <asp:DropDownList ID="dll" Runat="server">
> <asp:ListItem Value="0">one</asp:ListItem>
> <asp:ListItem Value="1">two</asp:ListItem>
> </asp:DropDownList>
> </ItemTemplate>
> </asp:TemplateColumn>
> </Columns>
> </asp:DataGrid>
> ch J
>
>
Wednesday, March 28, 2012
system.IO
sFile = x:\test\abcd.mdb
if (System.IO.File.Exists(sFile))
//do something
else
//do something else
my code is failing at Exists function. It does not find the file.
X:\ is a mapped drive. X drive has domain account permissions (like
domain\myLoginaccount). also I am runing my web application with default
security as annonymus user called domain\myLoginaccount
Why the Exsits function does not find the file. Am I missing any permissions
here...whats the best mthod to access the files from another machine thru
asp.net
thanks
cheers !I think there are 2 potential hurdles here:
1. does the account running the web page have privileges to access the
share? Be aware that as well as the IIS user and IIS impersonation, you also
have to consider which user the asp.net worker process is running as. This
is quite a complex subject and I'm afraid my knowledge is limited to the
general concept.
2. does the web app actually have the drive mapped? the web server will not
inherit mapped drives from a terminal session so unless you are mapping the
drive from the web app, I don't tihnk it will be there. I would suggest you
try again with a unc path.
Andy
"abcd" <abcd@.abcd.com> wrote in message
news:eXNa%23BpoFHA.3912@.TK2MSFTNGP10.phx.gbl...
> code snippet:-
> sFile = x:\test\abcd.mdb
> if (System.IO.File.Exists(sFile))
> //do something
> else
> //do something else
> my code is failing at Exists function. It does not find the file.
> X:\ is a mapped drive. X drive has domain account permissions (like
> domain\myLoginaccount). also I am runing my web application with default
> security as annonymus user called domain\myLoginaccount
> Why the Exsits function does not find the file. Am I missing any
> permissions here...whats the best mthod to access the files from another
> machine thru asp.net
> thanks
> cheers !
>
system.IO
sFile = x:\test\abcd.mdb
if (System.IO.File.Exists(sFile))
//do something
else
//do something else
my code is failing at Exists function. It does not find the file.
X:\ is a mapped drive. X drive has domain account permissions (like
domain\myLoginaccount). also I am runing my web application with default
security as annonymus user called domain\myLoginaccount
Why the Exsits function does not find the file. Am I missing any permissions
here...whats the best mthod to access the files from another machine thru
asp.net
thanks
cheers !I think there are 2 potential hurdles here:
1. does the account running the web page have privileges to access the
share? Be aware that as well as the IIS user and IIS impersonation, you also
have to consider which user the asp.net worker process is running as. This
is quite a complex subject and I'm afraid my knowledge is limited to the
general concept.
2. does the web app actually have the drive mapped? the web server will not
inherit mapped drives from a terminal session so unless you are mapping the
drive from the web app, I don't tihnk it will be there. I would suggest you
try again with a unc path.
Andy
"abcd" <abcd@.abcd.com> wrote in message
news:eXNa%23BpoFHA.3912@.TK2MSFTNGP10.phx.gbl...
> code snippet:-
> sFile = x:\test\abcd.mdb
> if (System.IO.File.Exists(sFile))
> //do something
> else
> //do something else
> my code is failing at Exists function. It does not find the file.
> X:\ is a mapped drive. X drive has domain account permissions (like
> domain\myLoginaccount). also I am runing my web application with default
> security as annonymus user called domain\myLoginaccount
> Why the Exsits function does not find the file. Am I missing any
> permissions here...whats the best mthod to access the files from another
> machine thru asp.net
> thanks
> cheers !
>
>
System.Messaging
Hello, I came across a tutorial on uploading files to a databaseand the example code given in it has the following code thatgives an error that says " Name 'Exc' is not declared.", when I build mysolution.
Catch Exc As Exception
Response.Write("Error: " & Exc.Message)
End Try
I'm trying to get up to speed with this dot net stuff by going through this and other tutorials. I have already added reference to the System.Messaging namespace to my application. What else must I do to make this work. Thank you in advance for your help.
You need an
Imports System.messaging
along with all the other Imports at the top of the program.
System.Media.SystemSounds not playing
The title is only half true, which is the thing that confuses me.
In my code behind, I am calling
System.Media.SystemSounds.Hand.Play();
whenever there is an incorrect input from the user. This works perfectly when I run it locally on my machine, but when I upload it to the server and run it from the website, the page works exactly the same except that there is no sound played. I've tried this with System.Media.SoundPlayer as well to the same effect. I'm doing the tests from the same computer. I've also remoted into the server and tried it there with no sound playing. The server is Windows Server 2003, running the project in Framework 2.0.
Does anyone know why this is a problem?
it's playing - on the server
as you said - you have it in the code-behind, which is executed on the server.
You would need something client-side to play through client browser.
Not sure how to do that
Aha, that's the problem. Thanks for that!
Just to test it, I ran IIS off of my computer and let some people make my computer ding repeatedly. I believe they enjoyed it far too much. I just tried embedding the Play() method in the .aspx file, but that doesn't work either.
I'm thinking I'll have to do some client-side scripting of some javascript in there. Something like
<%
if (bError)
{
%>
_javascript_
<%
}
I don't know a way to make a sound without a dialog box, however. I'll do some searching.
if you find the solution - post so others may benefit
mark the post as answered please....
Monday, March 26, 2012
System.Net.Mail
doesn't seem to work in ASP?
It is supposed to send mail to an SMTP server that requires a username and
password.
'create the mail message
'Dim mail As New MailMessage()
'set the addresses
'mail.From = New MailAddress("me@dotnet.itags.org.mycompany.com")
'mail.To.Add(test1@dotnet.itags.org.testdomain.com)
'set the content
'mail.Subject = "TEST TEST TEST This is an email"
'mail.Body = "this is the body content of the email."
'send the message
'Dim smtp As New SmtpClient("127.0.0.1")
'to authenticate we set the username and password properites on the
SmtpClient
'smtp.Credentials = New NetworkCredential("username", "secret")
'smtp.Send(mail)If you work thru my sample project ... at the blog, you'll find the
different switches you need to experiment with to get an "authentication"
email to work.
I have 1.1 and 2.0 syntaxes.
http://sholliday.spaces.live.com/ 2/8/2006
While the code is in C#, you'll at least see the properties you need to set.
You need to find the
TestApp_2_0 . Program.cs file.
Here is what to find ... under the 2/8/2006 entry
You can download the code HERE. (Right-Click and "Save As" works best)
"AbraAbraCadabra" <nws@.gsw-inc.comwrote in message
news:%23W2kW$6yGHA.1292@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
This is some code for VB that is supposed to work in ASP. How come it
doesn't seem to work in ASP?
It is supposed to send mail to an SMTP server that requires a username and
password.
>
>
'create the mail message
'Dim mail As New MailMessage()
>
'set the addresses
'mail.From = New MailAddress("me@.mycompany.com")
'mail.To.Add(test1@.testdomain.com)
>
'set the content
'mail.Subject = "TEST TEST TEST This is an email"
'mail.Body = "this is the body content of the email."
>
'send the message
'Dim smtp As New SmtpClient("127.0.0.1")
>
'to authenticate we set the username and password properites on the
SmtpClient
'smtp.Credentials = New NetworkCredential("username", "secret")
'smtp.Send(mail)
>
>
I tried your link on two different computers and they both crash about 10
seconds after viewing the first page. Is there a problem with your link?
"sloan" <sloan@.ipass.netwrote in message
news:eQwZRS7yGHA.4496@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
>
If you work thru my sample project ... at the blog, you'll find the
different switches you need to experiment with to get an "authentication"
email to work.
>
I have 1.1 and 2.0 syntaxes.
>
http://sholliday.spaces.live.com/ 2/8/2006
>
While the code is in C#, you'll at least see the properties you need to
set.
>
You need to find the
TestApp_2_0 . Program.cs file.
>
>
Here is what to find ... under the 2/8/2006 entry
You can download the code HERE. (Right-Click and "Save As" works best)
>
>
>
"AbraAbraCadabra" <nws@.gsw-inc.comwrote in message
news:%23W2kW$6yGHA.1292@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
>This is some code for VB that is supposed to work in ASP. How come it
>doesn't seem to work in ASP?
>It is supposed to send mail to an SMTP server that requires a username
>and
>password.
>>
>>
>'create the mail message
>'Dim mail As New MailMessage()
>>
>'set the addresses
>'mail.From = New MailAddress("me@.mycompany.com")
>'mail.To.Add(test1@.testdomain.com)
>>
>'set the content
>'mail.Subject = "TEST TEST TEST This is an email"
>'mail.Body = "this is the body content of the email."
>>
>'send the message
>'Dim smtp As New SmtpClient("127.0.0.1")
>>
>'to authenticate we set the username and password properites on the
>SmtpClient
>'smtp.Credentials = New NetworkCredential("username", "secret")
>'smtp.Send(mail)
>>
>>
>
>
Use a browser besides IE.
I think microsoft sent an update out for IE.. and it crashes when it goes to
a spaces.msn.com/somebody type site.
They redid the look/feel of the msn spaces.
I get the same issue sometimes.
I thought it was just me, but apparently not.
"AbraAbraCadabra" <nws@.gsw-inc.comwrote in message
news:evdOsLFzGHA.4044@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
I tried your link on two different computers and they both crash about 10
seconds after viewing the first page. Is there a problem with your link?
>
>
>
>
"sloan" <sloan@.ipass.netwrote in message
news:eQwZRS7yGHA.4496@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
If you work thru my sample project ... at the blog, you'll find the
different switches you need to experiment with to get an
"authentication"
Quote:
Originally Posted by
Quote:
Originally Posted by
email to work.
I have 1.1 and 2.0 syntaxes.
http://sholliday.spaces.live.com/ 2/8/2006
While the code is in C#, you'll at least see the properties you need to
set.
You need to find the
TestApp_2_0 . Program.cs file.
Here is what to find ... under the 2/8/2006 entry
You can download the code HERE. (Right-Click and "Save As" works best)
"AbraAbraCadabra" <nws@.gsw-inc.comwrote in message
news:%23W2kW$6yGHA.1292@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
This is some code for VB that is supposed to work in ASP. How come it
doesn't seem to work in ASP?
It is supposed to send mail to an SMTP server that requires a username
and
password.
>
>
'create the mail message
'Dim mail As New MailMessage()
>
'set the addresses
'mail.From = New MailAddress("me@.mycompany.com")
'mail.To.Add(test1@.testdomain.com)
>
'set the content
'mail.Subject = "TEST TEST TEST This is an email"
'mail.Body = "this is the body content of the email."
>
'send the message
'Dim smtp As New SmtpClient("127.0.0.1")
>
'to authenticate we set the username and password properites on the
SmtpClient
'smtp.Credentials = New NetworkCredential("username", "secret")
'smtp.Send(mail)
>
>
>
>
System.net.mail
Simple vb code, right?
Dim objSMTPAs New SmtpClient("mailserver.domain.com", 25)Dim objMsg asNew MailMessage("To@dotnet.itags.org.domain.com","from@dotnet.itags.org.domain.com","test","body testing")objSMTP.Send(objMsg)When I run the above code, I get an authentication failure. I've tried using a non-default authentication like this:
Dim objMsgAs New MailMessage("from@dotnet.itags.org.domain.com","To@dotnet.itags.org.domain.com","Test","Body of message. Testing 1 2 3")Dim objSMTPAs New SmtpClient("mail.server.com") objSMTP.UseDefaultCredentials =False Dim objCredsAs New NetworkCredential objCreds.UserName ="username" objCreds.Password ="password" objSMTP.Credentials = objCreds objSMTP.Send(objMsg) But I still get the same error. How do I give the mail server my username and password?what about putting settings in the configuration file?
<system.net><mailSettings> <smtp deliveryMethod="network"> <network host="mail.domain.com" userName="username OR DomainEmail" password="Password" defaultCredentials="true"/></smtp></mailSettings> </system.net>
have you tried like this ?
http://www.systemnetmail.com/faq/4.2.aspx
it's only slightly different
objSMTP.Credentials = New NetworkCredential("username", "secret")
system.net.mail - Help
i used system.web.mail in my previous codes.. now i cannot sendemail... when i used VWD it says that the code im using is obsolete,and that i have to use system.net.mail
here's the code i found in one of the threads
-- Begin Code --
Dim msg As New System.Net.Mail.MailMessage
Dim smtp As New System.Net.Mail.SmtpClient
With msg
.From = New System.Net.Mail.MailAddress("From Mail Address")
.To.Add(New System.Net.Mail.MailAddress("To Mail Address")
.Subject = "Important Message"
.IsBodyHtml = False
.Body = "This email is marked as urgent."
.Headers.Add("Importance", "High")
End With
Try
smtp.Host = "Host Server"
smtp.Send(msg)
Catch ex As Exception
'Handle error
End Try
-- End Code -- (thanks to mr. Jeremy Lucas)
but when i tried the code.. i encountered an 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:BC30002: Type 'System.Net.Mail.MailMessage' is not defined.
Source Error:
Line 105: Dim msg As New System.Net.Mail.MailMessage
Line 106: Dim smtp As New System.Net.Mail.SmtpClient
Line 107:
im trying to figure this out by importing namespaces like
<% Import namespace ="system.net.mail.smtpclient"%>
<% Import namespace ="system.net.mail.mailmessage"%>
still,, i get the same error.. please help... im totally lost.
I had asked about (and then figured out) some working code on this post
http://forums.asp.net/1007397/ShowPost.aspx
hope that helps
tnx for the reply ... i found out the error.. i have to change ASP.netversion to 2.xxxxxx now im having a new dilemma.. i dunno if i have topost this on a new thread.. but my problem now is thatwhen i tried the code.. it seems ok.. but when i check my mail.. its BLANK...
i checked the mailroot... seems like my mails are either in BADMAIL orin QUEUE... im sure i filled up all the necessary info.. im not surewhy its in BADMAIL..
i cant figure this out because.. months ago. when i usedsystem.web.mail. i can send mail within our connection (notes client)but cannot send outside of the company.
Please help.. im using WINXP.
System.Net.Mail class smtpdemo needs users address in message body from txt.emailAddress
/code/
Imports System.Net.Mail
PartialClass report_aspx
Inherits System.Web.UI.Page
ProtectedSub sendEmail_Click(ByVal senderAsObject,ByVal e _
As System.EventArgs)Handles sendEmail.Click
Dim sBodyAsString
Dim fileReaderBodyAsString
Dim fileReaderFormatAsString
Dim WebDirectoryAsString = Server.MapPath(".") &"\"
Dim fileNameAsString = WebDirectory
Dim htmlEmailFormatAsString = WebDirectory &"MailFormat.htm"
SelectCase Subject.Text
Case"Broken Link"
fileName = fileName &"BrokenLink.txt"
Case"Missing Picture"
fileName = fileName &"MissingPicture.txt"
Case"Typographical Error"
fileName = fileName &"TypoError.txt"
CaseElse
fileName = fileName &"other.txt"
EndSelect
fileReaderBody =My.Computer.FileSystem.ReadAllText(fileName)
fileReaderFormat =My.Computer.FileSystem.ReadAllText(htmlEmailFormat)
sBody = fileReaderFormat.Replace("BODYGOESHERE", _
messageBody.Text)
sBody = sBody.Replace("CONTENTGOESHERE", fileReaderBody)
sBody = sBody.Replace("SUBJECTGOESHERE", Subject.Text)
Dim toAddressAs MailAddress =New _
MailAddress(me@dotnet.itags.org.myemailaddress,"Webmaster")
Dim ccAddressAs MailAddress =New _
MailAddress(emailAddress.Text, emailName.Text)
Dim SenderAddressAs MailAddress =New _
MailAddress(emailAddress.Text)
Dim fromAddressAs MailAddress =New _
MailAddress(me@dotnet.itags.org.myemailaddress)
Dim eMailAs MailMessage =New _
MailMessage(fromAddress, fromAddress)
eMail.CC.Add(fromAddress)
eMail.Subject = Subject.Text
Dim htmlTypeAs System.Net.Mime.ContentType = _
New System.Net.Mime.ContentType("text/html")
Dim txtTypeAs System.Net.Mime.ContentType = _
New System.Net.Mime.ContentType("text/plain")
eMail.AlternateViews.Add( _
AlternateView.CreateAlternateViewFromString(sBody, htmlType))
eMail.AlternateViews.Add( _
AlternateView.CreateAlternateViewFromString(fileReaderBody & vbCrLf & messageBody.Text, htmlType))
Dim attchmentAs Attachment =New _
Attachment(WebDirectory &"goldbar.gif")
eMail.Attachments.Add(attchment)
Dim clientAs SmtpClient =New SmtpClient("myemailserver")
client.Send(eMail)
lblMessageSent.Text ="MESSAGE SENT"
emailAddress.Text =""
emailName.Text =""
messageBody.Text =""
EndSub
ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load
EndSub
EndClass
/end code/
/codebehind file/
Body = sBody.Replace("NAMEGOESHERE", emailName.Text)
sBody = sBody.Replace("EMAILFROMGOESHERE", emailAddress.Text)
/end codebehind file/
/mailformat.html/
<html><body><h1>SUBJECTGOESHERE</h1><imgsrc="goldbar.gif"/><br/>BODYGOESHERE
<br/>
<imgsrc="goldbar.gif"/><br/>
NAMEGOESHERE<br/>
EMAILFROMGOESHERE<br/>
<br/>
<blockquote>CONTENTGOESHERE</blockquote></body></html>
System.Net.Mail Error: Unable to read data from the transport connection: net_io_connectio
seem to have encountered it.
The code is straightforward:
MailMessage mail = new MailMessage(from, to, subject, body);
SmtpClient client = new SmtpClient("localhost");
client.Send (mail);
The code works fine on my development machine (XP Pro). When moved to
staging (2003 Server), I get the "connection closed" error. I've
confirmed the following:
-- "localhost" resolves to 127.0.0.1 (also tried using the loopback
address with the same error)
-- SMTP service is running on port 25
-- service is configured to relay mail
-- another app (Community Server) is using the service to send email
without any problems.
I'm at wit's end
TIAAs usual, this problem was resolved out not long after posting this
message. The problem was how the SMTP service was set up.
Specifically, the service has been bound to a specific IP address (not
the webserver's; see the "IP Address" dropdown in the "General" tab).
Once this was set to "(All Unassigned)". Everything worked fine.
Hopefully this message will save someone the hours of aggravation I
endured.
nate.strules@.gmail.com wrote:
Quote:
Originally Posted by
I've looked everywhere for an answer to this, but only a few people
seem to have encountered it.
>
The code is straightforward:
>
MailMessage mail = new MailMessage(from, to, subject, body);
SmtpClient client = new SmtpClient("localhost");
client.Send (mail);
>
The code works fine on my development machine (XP Pro). When moved to
staging (2003 Server), I get the "connection closed" error. I've
confirmed the following:
>
-- "localhost" resolves to 127.0.0.1 (also tried using the loopback
address with the same error)
-- SMTP service is running on port 25
-- service is configured to relay mail
-- another app (Community Server) is using the service to send email
without any problems.
>
I'm at wit's end
>
TIA
System.Net.Mail library problems
Hi everyone, I'm newbie on ASP.net and I was trying to to an application to send emails with the following code using System.net.mail namespace:
PrivateSub Envio_Correo(ByVal rutaAsString)'Creando la instancia del mensajeDim correoAsMailMessage = nothingcorreo.From =
New MailAddress("b98123839@dotnet.itags.org.usmp.edu.pe")correo.To.Add(
"amonasiq@dotnet.itags.org.usmp.edu.pe")correo.Subject =
"Archivo de Confirmación de matricula"correo.Body =
"Se adjunto archivo de confirmación de matricula de su respectiva facultad"correo.IsBodyHtml =
False'correo.Attachments.Add(New Attachment(ruta))correo.Priority = MailPriority.Normal
'Crando la instancia del SMTP clienteDim smtpAsNew SmtpClientsmtp.Host =
"192.168.1.53"Trysmtp.Send(correo)
Catch exAs SmtpExceptionlMenErr.Text =
"Paso 4: Enviando el correo: " + ex.Message.ToString()lMenErr.ForeColor = System.Drawing.Color.Red
EndTryEndSubBut always get the same error: Mailbox unavailable. The server response was: Error: Message content rejected
But if i use the namespace system.web.mail with almost the same code:
PrivateSub enviar_correo_antiguo(ByVal rutaAsString,ByVal facuAsString)Dim correoAsNew MailMessageDim adjuntoAsNew MailAttachment(ruta)
correo.From =
"desarrollo@dotnet.itags.org.usmp.edu.pe"correo.To = Devolver_mail_ora(facu)
correo.Subject =
"Archivo de Confirmación de matricula"correo.Body =
"Se adjunto archivo de confirmación de matricula de su respectiva facultad"correo.Attachments.Add(adjunto)
SmtpMail.SmtpServer =
"192.168.1.53"TrySmtpMail.Send(correo)
Catch exAs ExceptionlMenErr.Text =
"Paso 5: Enviando el correo: " + ex.Message.ToString()lMenErr.ForeColor = System.Drawing.Color.Red
EndTryEndSubI dont have any problem at all, Could anyone tell me what is wrong in my code?
Sincerly
Kryor
system.web.mail = asp.net version 1.1system.net.mail= asp.net version 2.0
I know system.web is for framework 1.1 and system.net is for 2.0 but why is working with the old namespace and not with the new one being almost the same code.
each website can only run 1 framework- even if both are installed.
It seems your website is configured to run framework 1.1 ( thats my guess, based on what you posted )
There is a tab in IIS where you set the version for each website.
System.NET is through sockets so you may have to add more code. Try the link below for more about System.NET.Mail. Hope this helps.
http://www.systemnetmail.com/
System.Net.Mail issue - html AlternateView losing period in href
--
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlSB.ToString(),Encoding.GetEncoding(0),MediaTypeNames.Text.Html);
--
I am dumping it to a text file locally. In the instance where there is a wrap in the body which contains an a href, and there is a period just AFTER the wrap, it drops the period
ex of the physical email file:
blah blah blah blah <a href="http://links.10026.com/?link=http://forums.asp=
.net>Asp Forums</a>blah blah blah blah bla=
(note the period on the new line)
shows up as -
blah blah blah blah <a href="http://links.10026.com/?link=http://forums.aspnet>Asp Forums</a>blah blah blah blah bla
(note the missing period between asp and net)
Any ideas?
thanks
m
Since I have not gotten a response at all, should I assume that this is an unfixable bug and abandon system.net.mail?
thanks
Saturday, March 24, 2012
system.net.socket question
Public Sub StartListening()
' Data buffer for incoming data.
Dim bytes() As Byte = New [Byte](128000) {}' Establish the local endpoint for the socket.
Dim ipHostInfo As IPHostEntry = Dns.Resolve(Dns.GetHostName())
Dim ipAddress As IPAddress = ipHostInfo.AddressList(0)
Dim localEndPoint As New IPEndPoint(ipAddress, XXXXX)' Intializes a TCP/IP socket.
Dim listener As New Socket(AddressFamily.InterNetwork, _
SocketType.Stream, ProtocolType.Tcp)' Bind the socket to the local endpoint and listen for incoming
' connections.
Try
listener.Bind(localEndPoint)
listener.Listen(100)While True
' Set the event to nonsignaled state.
allDone.Reset()' Start an asynchronous socket to listen for connections.
listener.BeginAccept(New AsyncCallback(AddressOf AcceptCallback), _
listener)' Wait until a connection is made before continuing.
allDone.WaitOne()
End While
Catch e As Exception
'Print out error message to log file
' Console.WriteLine(e.ToString()) '************
End Try
End SubPrivate Sub AcceptCallback(ByVal ar As IAsyncResult)
' Signal the main thread to continue.
allDone.Set()' Get the socket that handles the client request.
Dim listener As Socket = CType(ar.AsyncState, Socket)
Dim handler As Socket = listener.EndAccept(ar)' Create the state object.
Dim state As New StateObject
state.xSocket = handler
handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, _
New AsyncCallback(AddressOf readCallback), state)End Sub
how do I get the IP address from the clients that connect to my sever?nevermind...i figured it out
Trey