|
Here's what I use to send email:
public static void
SendEmail
(
string Sender
,
string Recipient
,
string Subject
,
string Body
,
string SmtpServer
,
System.IO.FileInfo[] Files
)
{
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage ( Sender , Recipient ) ;
if ( Files != null )
{
System.Text.StringBuilder temp = new System.Text.StringBuilder ( Body ) ;
temp.Append ( string.Format
(
"\n\n{0} attached file{1}:"
,
Files.Length
,
Files.Length==1?"":"s"
) ) ;
foreach ( System.IO.FileInfo att in Files )
{
if ( att != null )
{
temp.Append ( "\n" + att.Name ) ;
if ( att.Exists )
{
msg.Attachments.Add ( new System.Net.Mail.Attachment ( att.FullName ) ) ;
}
else
{
temp.Append ( " -- does not exist!" ) ;
}
}
}
Body = temp.ToString() ;
}
msg.Subject = Subject ;
msg.Body = Body ;
System.Net.Mail.SmtpClient cl = new System.Net.Mail.SmtpClient ( SmtpServer ) ;
cl.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials ;
cl.Send ( msg ) ;
}
|
|
|
|
|
Do you use this on a exchange server? It appears you might be passing the mail.domain.com for what it should login with.
|
|
|
|
|
Brad Wick wrote: Do you use this on a exchange server?
The service that uses that code runs on the same box as the Exchange server, but it doesn't have to.
Brad Wick wrote: It appears you might be passing the mail.domain.com for what it should login with.
Not to my knowledge.
|
|
|
|
|
in case this isn't already what you're using, there's also MS Outlook interop in addition to PIEBALDs solution:
simple example[^]
more than you ever wanted to know[^]
not sure if it's going to show the outlook popup window, but it's a nice thing to know about
|
|
|
|
|
I am trying to store the values of 5 textbxes of a form fr each user into an arrayList and then iterate through the list fr the details of each usern using a foreach statement. I have a problem in writing the code that implements it. ex: UserId, Fname, Lname, addr, city, state -> save these values into an array list and iterate thrugh the list front and back. _-- Please help me out
Shashank
|
|
|
|
|
Theres alot of way doing this. Least of code way would be:
ArrayList lst = new ArrayList();
Foreach( TextBox txt in Form.Controls)
{
lst.Add(txt.Text);
}
//now your Arraylist contains all the data in textboxes on the form.
Hope it helps you.
PS:My C# syntax needs some dusting-off, so the code above may not compile as is - but .NET concept works.
|
|
|
|
|
I need to create an application that will monitor iTunes.
Currently I am using the OnDatabaseChange event to do this, the problem is I am having trouble working out (from the changedObjectsIDs) which items have been added and which have had their metadata edited.
I'm not sure if that's clear. More information available if requird.
Any help would be very much appreciated.
Freedom is the right to say that 2+2=5 if this is so everything else will follow.
|
|
|
|
|
Hello sirs,
I have exhausted my resources and have come seeking help.
I have a windows .net application A written in C# and I have another windows .net application written in C# called B.
B is a simple Form with a button and a listbox. It contains an arrayList that when the button is pressed spits out all the strings in it.
A is ment to Run B and be able to change its arraylist to add strings to it and possible call functions in B.
Example:
I run A which Loads B
B's form shows up and I click the button which displays Hello World.
I goto the A form which has some input to add strings to Bs arrayList.
I reclick Bs button and the new strings show up.
Any ideas?
|
|
|
|
|
|
I need my application to respond when a certain other application window is resized. The other app is completely external (I did not write it, I don't have the source, etc).
Is there a way to do this via .NET structures, or do I have to use Windows Messages? Either way, I'm not sure how this is to be done. If it's the latter case, how do I get the resize message that (I presume) is generated when a user resizes the external application, assuming I already have the windows-handle to the app?
|
|
|
|
|
I guess you have two options here:
a) intercept the window messages (WM_SIZE/WM_RESIZE) of the other window using a hook
b) periodically get the size of the other window in a timer and compare it with the size of the last timer tick (seems like a bad solution, but easier than using a hook)
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I suspect you will need global hooks which according to ms cannot be implemented in .NET but there is an article on codeproject explaining how to do it.
|
|
|
|
|
Hi All;
I'm working in VS2005, and have a DataGridView that draws from a datasource. Is there a way to change a column to be a link style column after the DataGridView populates? Here's how I populate it:
<br />
DataSet ds = new DataSet();<br />
dgvShipmentHistory.DataSource = null;<br />
SqlDataAdapter da = new SqlDataAdapter(mySQLClass.Query, mySQLClass.SqlCon);<br />
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;<br />
da.Fill(ds, "ShipmentHistory");<br />
dgvShipmentHistory.DataSource = ds.Tables[0];<br />
dgvShipmentHistory.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);<br />
I want to be able to change one of the columns to be a link type column so that users can click the hyperlink and I can throw up a page.
Thanks
|
|
|
|
|
|
|
Did u try using DataGridViewLinkColumn?
If ur grid id bound to datasource, goto properties -> Columns -> select the appropriate column from ur columns list -> and change ColumnType property
Let me know if that works or am i thinking too simple.
Ketty
|
|
|
|
|
The only property I can see is the CellStyle property, I dont see a ColumnType property on the datagridview column.
|
|
|
|
|
There is a DataGridViewLinkColumn class, but dont know if that will help me once the grid has been populated already, as I'm unsure how to change the type of column.
|
|
|
|
|
This is simple Designer generated code.
How to reach that property.
1. Select ur DataGridView control on designer.
2. F4
3. Columns (collection)
4. Select <column1>
5 On right side u see all column properties.
6. Change ColumnType to DataGridViewLinkColumn
<br />
namespace WindowsApplication1<br />
{<br />
partial class Form1<br />
{<br />
private System.ComponentModel.IContainer components = null;<br />
<br />
protected override void Dispose(bool disposing)<br />
{<br />
if (disposing && (components != null))<br />
{<br />
components.Dispose();<br />
}<br />
base.Dispose(disposing);<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
<br />
private void InitializeComponent()<br />
{<br />
this.components = new System.ComponentModel.Container();<br />
this.dataGridView1 = new System.Windows.Forms.DataGridView();<br />
this.actionTypesBindingSource = new System.Windows.Forms.BindingSource(this.components);<br />
this.fISM0702DataSet = new WindowsApplication1.FISM0702DataSet();<br />
this.actionTypesTableAdapter = new WindowsApplication1.FISM0702DataSetTableAdapters.ActionTypesTableAdapter();<br />
this.actionTypeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewLinkColumn(); this.descriptionDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();<br />
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();<br />
((System.ComponentModel.ISupportInitialize)(this.actionTypesBindingSource)).BeginInit();<br />
((System.ComponentModel.ISupportInitialize)(this.fISM0702DataSet)).BeginInit();<br />
this.SuspendLayout();<br />
this.dataGridView1.AutoGenerateColumns = false;<br />
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;<br />
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {<br />
this.actionTypeDataGridViewTextBoxColumn,<br />
this.descriptionDataGridViewTextBoxColumn});<br />
this.dataGridView1.DataSource = this.actionTypesBindingSource;<br />
this.dataGridView1.Location = new System.Drawing.Point(213, 281);<br />
this.dataGridView1.Name = "dataGridView1";<br />
this.dataGridView1.Size = new System.Drawing.Size(240, 150);<br />
this.dataGridView1.TabIndex = 3;<br />
this.actionTypesBindingSource.DataMember = "ActionTypes";<br />
this.actionTypesBindingSource.DataSource = this.fISM0702DataSet;<br />
this.fISM0702DataSet.DataSetName = "FISM0702DataSet";<br />
this.fISM0702DataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;<br />
this.actionTypesTableAdapter.ClearBeforeFill = true;<br />
this.actionTypeDataGridViewTextBoxColumn.DataPropertyName = "ActionType";<br />
this.actionTypeDataGridViewTextBoxColumn.HeaderText = "ActionType";<br />
this.actionTypeDataGridViewTextBoxColumn.Name = "actionTypeDataGridViewTextBoxColumn";<br />
this.actionTypeDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;<br />
this.actionTypeDataGridViewTextBoxColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;<br />
this.descriptionDataGridViewTextBoxColumn.DataPropertyName = "Description";<br />
this.descriptionDataGridViewTextBoxColumn.HeaderText = "Description";<br />
this.descriptionDataGridViewTextBoxColumn.Name = "descriptionDataGridViewTextBoxColumn";<br />
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);<br />
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;<br />
this.ClientSize = new System.Drawing.Size(636, 562);<br />
this.Controls.Add(this.dataGridView1);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
this.Load += new System.EventHandler(this.Form1_Load);<br />
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();<br />
((System.ComponentModel.ISupportInitialize)(this.actionTypesBindingSource)).EndInit();<br />
((System.ComponentModel.ISupportInitialize)(this.fISM0702DataSet)).EndInit();<br />
this.ResumeLayout(false);<br />
<br />
}<br />
<br />
#endregion<br />
<br />
private System.Windows.Forms.DataGridView dataGridView1;<br />
private FISM0702DataSet fISM0702DataSet;<br />
private System.Windows.Forms.BindingSource actionTypesBindingSource;<br />
private WindowsApplication1.FISM0702DataSetTableAdapters.ActionTypesTableAdapter actionTypesTableAdapter;<br />
private System.Windows.Forms.DataGridViewLinkColumn actionTypeDataGridViewTextBoxColumn;<br />
private System.Windows.Forms.DataGridViewTextBoxColumn descriptionDataGridViewTextBoxColumn;<br />
}<br />
}<br />
Are you binding ur grid on runtime????
Ketty
|
|
|
|
|
Yes, the grid is bound at runtime, so although I know what the columns will be for the most part, they could change.
|
|
|
|
|
I need to write a performance driven utility that allows user to write C# code in a text area. When they click on execute to see what is the final out, utility should complie and run the code written by user as if it is a function body.
e.g. I am trying to achieve:
<br />
private void ExecuteUser()
{<br />
<br />
<br />
<br />
}<br />
I am not a C# coder for past few years , so any code snippet would be awesome. We are using .Net 2.0. VS 2005.
Ketty
|
|
|
|
|
You can't put code into an existing method. You have to compile the code into a new assembly.
Take a look at the Microsoft.CSharp.CSharpCodeProvider class.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks, I did see an example of "Microsoft.CSharp.CSharpCodeProvider class" on CodeProject, if you or any body has used it. Is it performance promising?
Ketty
|
|
|
|
|
private void ExecuteUser()
{
if(txtUserCode.Text != "while(true){}"){
}
}
Feel free to use this as a safeguard after you get the rest of it figured out
|
|
|
|
|
I am not quite sure if I understand the idea completely.
Please advice.
Ketty
|
|
|
|