|
You can use the MailMessage Object to fill the from, to, subject, address. and then use the smtpclient object to set the SMTP server to be used and to send the mail Message.
jamil Abou khalil
|
|
|
|
|
Thanks!for the information you have given i have found a lot of details about how to go witht the mail application developement. but still if you would provide me some links which can give me the download of the sample mail application right from the scratch. it would be more help full.....
chandu
|
|
|
|
|
well i have made this app long back.. so here is the details..
first include namespace
using System.Web.Mail;
then follow these steps :-
MailMessage mail = new MailMessage();
mail.From = from;
mail.To = to;
mail.Subject = sub;
mail.Body = body;
SmtpMail.SmtpServer = server;
SmtpMail.Send(mail);
I should this should help you. and if you still fce any problem contact me
<<realin wuzz="" here="">>
|
|
|
|
|
Thanks! a lot for the help now i have got a bit idea how to go ahead with the Application. but now i am planning the desktop mail application like Outlook, so if you help me out how to go ahead it will be more helpfull...
chandu
|
|
|
|
|
Hi…
In my application…I am trying to add data received on comport in a rich text box. Rich text box is on second form & my SerialPort.datareceived event is on first form. Here is my sample code…
form2 f2 = new form2();
Serialport.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
ReceivedData = comport.ReadExisting();
f2.Controls[0].Invoke(new EventHandler(delegate{f2.Controls[0].AppendTextReceivedData);}));
}
But I am getting error on the staement-
f2.Controls[0].AppendText(ReceivedData);
Error is - ('System.Windows.Forms.Control' does not contain a definition for 'AppendText')
I have only one rich textbox control on form2…
What is the problem…why I am unable to access "Appendext" method for the rich text box on ‘form2’ from 'form1'
Thanks,
Vinay
|
|
|
|
|
test two point:
1, is the RichTextBox in f2 accessable? use public test it again.
2, f2.Controls[0] is a control. if you can sure it is a RichTextBox, then test these
<br />
RichTextBox r = f2.Controls[0] as RichTextBox;<br />
if (r != null)<br />
{<br />
}
hoping this help.
|
|
|
|
|
I tried with u told...
But my richtextbox in f2 is not accessable from f1...Although declared it as public.
& RichTextBox's TabIndex is 0...
Thanks for your reply,
Vinay
|
|
|
|
|
Sorry 1 braket was missing...
Statement should me like this...
f2.Controls[0].Invoke(new EventHandler(delegate{f2.Controls[0].AppendText(ReceivedData);}));
& i am getting error on this staement for AppendText method...
Thanks,
Vinay
|
|
|
|
|
Hi!
If you read the error message (that's usually the prerequisite for finding out what's wrong ) you'll see that the compiler tells you that Control doesn't have a method AppendText .
The Controls collection holds Control s, not RichTextBox es, so the error message can be explained easily.
Use ((RichTextBox)f2.Controls[0]).AppendText(...) to get rid of the compiler error.
But keep in mind that the code above is bad style. It's easy to add another control to the form and suddenly your RichTextBox isn't Controls[0] anymore - an InvalidCastException will result.
I think it's better to explicitely expose the RichTextBox as a property of f2.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi...
i tried your suggestion
((RichTextBox)f2.Controls[0]).AppendText(...)
but its didnt worked.
Can u tell me what you want to say exactly with-
"explicitely expose the RichTextBox as a property of f2."
Thanks,
Vinay
|
|
|
|
|
Modify your class form2 to contain
public RichTextBox MyRichTextBox
{
get {
return richTextBox1;
}
} and use f2.MyRichTextBox instead of f2.Controls[0] .
And by the way "its didnt worked" is not helpful at all - if you don't tell us what the problem/error message is exactly we cannot help you.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thanks but...its not working...
Here is some more information ...Can u please help me...?
<br />
<br />
<br />
public SerialPort comport = new SerialPort();<br />
<br />
public Form f1;<br />
<br />
f1 = new ChildForm();<br />
f1.MdiParent = this;<br />
<br />
comport.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);<br />
<br />
<br />
private void btn_Senddata_Click(object sender, EventArgs e)<br />
{<br />
comport.open();<br />
comport.Write("This is the text to be transmitted");<br />
<br />
}<br />
<br />
public void port_DataReceived(object sender, SerialDataReceivedEventArgs e)<br />
{<br />
string ReceivedData = comport.ReadExisting();<br />
<br />
ReceiveLog(LogMsgType.Incoming, ReceivedData);<br />
<br />
if(f1.Controls[0].InvokeRequired)<br />
{<br />
f1.Controls[0].Invoke(new EventHandler(delegate<br />
{ f1.Controls[0].AppendText(ReceivedData); <br />
}));<br />
}<br />
<br />
<br />
<br />
<br />
<br />
RichTextBox MyRichTextBox = new RichTextBox();
<br />
<br />
<br />
<br />
What is the problem,i am not able to understand...
Thanks,
Vinay
|
|
|
|
|
Once again: Please read the error messages you get and try to understand them.
If you don't understand them, post them here so that we can help you!
With the code snipplet you posted I think the problem could be that you declared f1 as Form but in fact it's an instance of ChildForm .
The class ChildForm does have a public RichTextBox named MyRichTextBox , the class Form doesn't.
So to get your code to work you should change public Form f1; to public ChildForm f1; and your DataReceived event handler should read
string ReceivedData = comport.ReadExisting();
ReceiveLog(LogMsgType.Incoming, ReceivedData);
if(f1.MyRichTextBox.InvokeRequired)
{
this.Invoke(new EventHandler(delegate
{ f1.MyRichTextBox.AppendText(ReceivedData); }
));
} else {
f1.MyRichTextBox.AppendText(ReceivedData);
}
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
I am designing a workflow for SPS2007.In this i am creating six task by workflow.I got problem when I want to use InfoPath form, in Task Edit form in Task List.
Also I want to open All the detials of Six task created in Single Form and want to edit that InfoPath form.
bharat sukhwal
|
|
|
|
|
Hi All,
I have a compeleted project that uses ms access database and some images and crystal reports, how can I make an installation file (Setup file). concerning the directory path for db file. Also, in crystal reports I had to specify the db file path in side the code. I tried the built in component in VS2005 but I couldn't.
Very Urgent, Could any one help
|
|
|
|
|
You may set the db connection of Crystal Reports in code.
I used CrystalReport before, but I don't have these sample code at home.
Please get this from MSDN.
hoping this help.
|
|
|
|
|
I am replying for what i got to know about your unclear statements, i guess your problem is that when u install some application, then it doesnt find it resources like images,icons, bitmaps after installation, well mate.. for that while making setup file, Include them in a wizard and then include this line
AppDomain.CurrentDomain.BaseDirectory
it will refer to the current installation directry or from where the exe is being run
enjoy !
if u face any problem do contact me
|
|
|
|
|
Thank realin for your reply,
This is a part of my code in the report viewer:
-----------------------------------------
int slach = Application.ExecutablePath.LastIndexOf('\\');
string dbLocation = Application.ExecutablePath.Substring(0, slach) + "\\Database\\hall.mdb";
ReportOkRes1.DataSourceConnections[0].SetConnection(dbLocation, dbLocation, false);
-----------------------------------------
It works fine in VS2005 but when I do the Setup project, and do the installation the application didn't work. I am sure that the problem is in reading from the db file "It does not find it".
|
|
|
|
|
Im a begining C# programmer and was hoping you guys could help me. Im working on my first real project and I am a little confused on how exactly to set it
up. I've read so many articles on this, but they all seem to be saying different things. Here is a psuedo code example of my current setup:
class EmployeeDA<br />
{<br />
public void Insert(Employee emp)<br />
{<br />
}<br />
}<br />
<br />
class Employee<br />
{<br />
private int id;<br />
private string name;<br />
private EmployeeDA = new EmployeeDA();<br />
<br />
public void Insert()<br />
{<br />
EmployeeDA.Insert(this);<br />
}<br />
}<br />
<br />
class Employees : List<Employee><br />
{<br />
public void AddEmployeesToTable()<br />
{<br />
foreach(Employee emp in this)<br />
emp.Insert;<br />
}<br />
}
Is this correct? I know there are many different ways to do it, so maybe "correct" isnt the right word. I guess what I want to know is if there is a "better" way of doing it. Are there any glaring issues with the way I am doing it currently?
Thanks
|
|
|
|
|
I think the architecture must depend on the project design.
If your project is not a complicated one, may be two layers would be a better one. I mean 'the data layer' and 'the business layer'.
|
|
|
|
|
Hi
As you mentioned there is no correct architecture.When you are designing a solution you should consider the domain of the problem that you are solving.
There are lots of patterns that you can choose from ( for example Data Access Objects and Active record)
If you are working on a small project ( and you don't expect it to become a large application in future) you can mix up the Data Access and the business layer or if you prefer you can have both in your project (It's not very hard to split them afterwards)
Be careful not to mix up your user interface layer with your business layer since it's very hard to refactor them afterwards.
Take a look at Martin Fowler's articles at his site (www.matinfowler.com)
and specially take a look at his Enterprise patterns.
Good Luck
|
|
|
|
|
Ok first off, I am very new to all of this C# stuff - so be gentle.
I have a windows form with a simple table . I am not using the data grid. but just displaying one record at a time.
I want to be able to determine which row of data I am currently viewing in the form and how to programatically change that row to display another.
For instance If the user clicks on a Search Button, it will take them to a modal form which will allow them to select a record and return the Key Value to the calling form, and select that row to display on the form.
Have searched now for days but am no closer to the answer.
John Martin
|
|
|
|
|
Hi
As far as I know a data table is not a cursor (but as its name says is a table or at least a snapshot of a table) then there's no current row when you are working with a table.
If you like to find a row within a table you can use its defualt data view and use its Find method which has some overloads.
(for example myTable.DefualtView.Find(key))
You can have a local variable that works as a bookmark and shows the current row index then you can retrieve current row using DataTabe.Rows indexer for example
int currentRow=1;
DataRow row=myTable.Rows[currentRow];
then you can implement some methos to navigate through your data table (currentRow+=1,currentRow-=1)
Good Luck
|
|
|
|
|
mmm
It seems that I know even less than I thought.
I have tried looking at this from all angles - to no avail.
Let's say that you are using the customer table in the Northwind DataBase.
You add a new customer. That customer is appended to the end of the table.
But I want to refresh the dataSet so that it is :
a. In Alphabetical order again. - this I can do. But it takes the focus back to the first row in the Data Set.
B. The row that is displayed on the form is the row that I have just added. "Eg Smith" and the next button will then display the row that follows Smith.
It is this latter aspect that I find hard to accomplish. If I can do this, then I feel certain that I can do the rest of what I want.
Any specific clues on this would be greatly appreciated.
John Martin
|
|
|
|
|
Hi
You can hold the key of a new row that has been added and set your current row to this new row (using sort and find metohd)
if you sort your table using its default view property (myTable.DefaultView.Sort="Field1 DESC,Field2"; ) then the next button will show the next record according to sorted key.
But I have a question to ask, if there's only one record showing to user each time , why do you load all the data to a data table ? you can load a record whenever it's needed.
for example if you have a code field that you want to use as your sort key you can get the next record using :
<br />
SELECT TOP 1 * FROM myTable WHERE code>@currentCode ORDER BY CODE<br />
and you can get the previous record using :
<br />
SELECT TOP 1 * FROM myTable WHERE code<@currentCode ORDER BY CODE DESC<br />
Getting the first and last records is also very easy.
<br />
SELECT TOP 1 * FROM myTable ORDER BY Code
SELECT TOP 1 * FROM myTable ORDER BY Code DESC
<br />
The good news is that you can find your record before loading it to your app thus only the needed data is loaded.
Regrads
|
|
|
|