|
Luc Pattyn wrote: I don't really want to receive e-mails that you consider too large
Neither do I, but you know those MBA-types and their love of Excel...
|
|
|
|
|
Hiya,
For me I found that disposing the client and or message releases the file lock.
Also, there is a problem sending emails over 4mb in size (this is if you do not know about it).
I would use the following: Net.Mail.Attachment.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit
kind regards
Dan
|
|
|
|
|
Agreed - the file remains locked until the Attachment instance is disposed. Calling Dispose on the MailMessage instance disposes of all attachments for the message.
protected virtual void Dispose(bool disposing)
{
if (disposing && !this.disposed)
{
this.disposed = true;
if (this.views != null)
{
this.views.Dispose();
}
if (this.attachments != null)
{
this.attachments.Dispose();
}
if (this.bodyView != null)
{
this.bodyView.Dispose();
}
}
}
public void Dispose()
{
if (!this.disposed)
{
foreach (Attachment attachment in this)
{
attachment.Dispose();
}
base.Clear();
this.disposed = true;
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Did you try using your second approach, but with a FileInputStream (or whatever the dotNet equivalent is)?
Just change
Stream stream = new MemoryStream(File.ReadAllBytes(filename));
to
Stream stream = new FileInputStream(filename);
and retain the cleanup loop at the bottom.
This avoids the memory stream.
|
|
|
|
|
Thanks for the suggestion. I don't have time to test that at the minute but I have put a TODO so will give it a go at some point
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
The C# 4.0 compiler is slow on my 4-core laptop. I noticed only one core is busy when compiling. Is C# compiler multi-core aware?
|
|
|
|
|
AFAIK it is not. However you may be interested in this[^]. I haven't tried it yet.
|
|
|
|
|
Sorry, but the link is for C++ not C#...
Daniel Rühmer
Application engineer for Measurement Software
|
|
|
|
|
sorry, my mistake.
|
|
|
|
|
|
I am writting a windows service in .net 4.0 for monitoring purposeson regular intervals.
How is it possible to send an email from within this windows service please?
Thanks
|
|
|
|
|
|
I use this:
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.UseDefaultCredentials = true ;
cl.Send ( msg ) ;
return ;
}
|
|
|
|
|
Here's how you bind to Dependency Property "CtrlXOffset" -
<UserControl x:Class="..."
x:Name="MyCtrl"
...
<aaa.SomeControl Name="xamTSChart" HorizontalAlignment="Left" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch">
<aaa.SomeControl.RenderTransform>
<TranslateTransform
X="{Binding Path=CtrlXOffset, ElementName=MyCtrl, Mode=OneWay}"
Y="0" />
</aaa.SomeControl.RenderTransform>
</aaa.SomeControl>
...
</UserControl>
This is cool - I get the result I wanted.
However, can I do this with regular CLR Properties? How'd I rewrite the binding expression?
Thanks
http://en.csharp-online.net/WPF_Concepts%E2%80%94Dependency_Property_Implementation[^]
dev
|
|
|
|
|
You don't need to rewrite the binding expression. The binding engine also binds to POCO as well. BTW, you should have asked this in the WPF/Silverlight forum.
|
|
|
|
|
|
i use VS2005(C#2.0) and OS is Winxp.
i find some code like this:
[DllImport("dxva2.dll", EntryPoint = "GetMonitorTechnologyType", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetMonitorTechnologyType(
IntPtr hMonitor, ref NativeStructures.MC_DISPLAY_TECHNOLOGY_TYPE pdtyDisplayTechnologyType);
but i don't know how use it to get the local machine's monitor type.
Thank you!!!
modified on Monday, December 6, 2010 4:42 AM
|
|
|
|
|
A quick google using your subject line as the search term gave this at MSDN: How to detect display type : CRT or LCD ?[^] as the top link, which includes full source code.
Perhaps you should consider improving your Google-Fu?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
yes, i google it.the answer's development is vs2008,and i try to tranlate it to vs2005
but failed.but i think it should use the code just i pasted.
|
|
|
|
|
That code shouldn't be too difficult to convert down into a 2005 project/class. If you have specific problems related to this, perhaps you could post those issues to the Q&A section for specific answers which are much more difficult to present here in the forum.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
scoket wrote: i find some source like this
You "found" source? At what site have you uncovered it?
I are Troll
|
|
|
|
|
just a joke.i have update my content.
|
|
|
|
|
HI, Thanks in Advance.
In Our project we need to send SMS for alert . but default we can acheive send sms through some Gateway using internet. but in our case we need to send without internet connection . our application use only with in the network ( LAN ). Please give me some idea if u have . can we done using GPRS connection. please give some more idea ...
Thanks...
|
|
|
|
|
|