|
Here is the source code that i had used to send an email with attachments via Outlook(minimum version is 2000)
Outlook.Application oApp;
Outlook._NameSpace oNameSpace;
Outlook.MAPIFolder oOutlookFolder;
oApp = new Outlook.Application();
oNameSpace= oApp.GetNamespace("MAPI");
oNameSpace.Logon(null,null,false,true);
oOutlookFolder = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
Outlook._MailItem oMailItem = (Outlook._MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
Outlook.Inspector myinspector;
myinspector = oApp.ActiveInspector();
oMailItem.Display(false); //display the blank email first
oMailItem.Subject = "Email with Attachments";
//filename is a string which represents the filepath of the file
//display_filename is a string which is the actual filename of the attachment
oMailItem.Attachments.Add(filename,1,1,display_filename);
oMailItem.Display(true); //display the email with the actual attachment.
To determine different versions of outlook you can try the version Method from the Outlook Object model as follows:
Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
string outlookVersion = oApp.Version;
I hope this helps.
cheers
-- modified at 17:34 Sunday 18th December, 2005
edit: The code in this sample will work with Outlook Object models 9.0,10.0 and 11.0.
|
|
|
|
|
This looks great, thanks. Now, what do I need to make this work ? Do I import Outlook COM dlls, or do I need the VS2005 Tools for Office ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
you dont need VS2005 tools for Office to use the Outlook COM dlls (Outlook object model). You can simply add the Outlook Object model via Add References (COM) in any visual studio IDE. You need to ensure that you have outlook installed on your development PC. If you dont then you can download the "Office XP Primary Interop Assembles" setup file from microsoft.com. This setup file will contain all the Office XP interop dlls associated with say Outlook, Word, Excel etc.
Once you have added the Outlook reference to your project simply type:
using microsoft.office.interop.outlook
hope this helps.
|
|
|
|
|
Perhaps an easier solution would be to cc the sender and have the emails filtered into a special folder. Or cc the email to a special address for this purpose only.
|
|
|
|
|
I want check if the user press the F1 to F12 keys
i try put it under keypress method of the form but the F1 to F12 key is not captured by key press event
i want to know how do i trigger F1 to F12 keys
thanks in advance....
Jalil
|
|
|
|
|
have you tried using the KeyDown eventhandler an example would be
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (Keys.F12.ToString() == e.KeyCode.ToString())
{
MessageBox.Show("F12 Key Pressed");
}
else
{
MessageBox.Show("F12 Key was not Pressed");
}
}
|
|
|
|
|
|
thanks for the reply it works.
|
|
|
|
|
I need to flush the IconCache. So i did this TweakUI thingy (iconsize - 1, refresh, iconsize + 1, refresh).
Key = Microsoft.Win32.Registry.CurrentUser;
Key = Key.OpenSubKey(@"Control Panel\Desktop\WindowMetrics", true);
Key.SetValue("Shell Icon Size", (Size-1).ToString());
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS, 0);
Key.SetValue("Shell Icon Size", Size.ToString());
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS, 0);
Key.Close();
i am using this DllImport
[DllImport("user32.dll")]
static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
and these constants:
HWND_BROADCAST = 0xffff;
WM_SETTINGCHANGE = 0x001A
SPI_SETNONCLIENTMETRICS = 0x002A;
so i have the flush most of the time BUT the app stops at the 2nd send message somehow. anybody has an idea why?
|
|
|
|
|
Which app freezes? The one sending the message (code posted above) or the one that you're trying to get to update? If it's the one above it's probably another app not handling the broadcast fast enough. I believe that the SendMessage will not return in this case until all of the apps have handled HWND_BROADCAST. Can you change it to a PostMessage instead?
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
Hi all.
I saing from the beginning : My English is very bad!!!:-OOk,i am asking my questions...
I ManagementObjectSearcher ' s wanting to use sql clause constructor.Which can i sql clause to this constructor???Can you give them list to me....
Example:
private static System.Management.ManagementObjectSearcher nesne=new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
"SELECT * FROM Win32_DiskDrive" <<<<----- As Of this .I want to my can use sql clause...Please help me!!!
Thanks...
|
|
|
|
|
|
Hi,
I'm writing a program that uses an external service.
My problam is that the external service does'nt free it's memory - and after a while it increases and slows the system. Programs like FreeRam or cacheman free the service memory (which is running in an exe process) with no problem.
I want to be able to free the process's memory using my own code. How do I do that? What API are involved and how do I use them?
Thanks
oren_mh
|
|
|
|
|
orenmh wrote: Programs like FreeRam or cacheman free the service memory (which is running in an exe process) with no problem
I've read reports of these programs. They are supposedly a sham and don't really do anything other than trick you into thinking that is has done something useful. Most of the time they make the overall situation worse.
An external process that has no knowledge of an application cannot force it to free RAM, it can only trick it into paging memory in RAM to the swap file. This means that more RAM is freed up, but slows down already running applications because they have to be swapped back to main memory in order to run at some later point.
orenmh wrote: I want to be able to free the process's memory using my own code. How do I do that?
If you have the source code of the service, then you can re-write it to be more memory efficient.
orenmh wrote: What API are involved and how do I use them?
DisplaceExistingProgramsToVirtualMemory()
{
byte[] bigBlockOfMemory = new byte[1048576*512];
}
That ought to do it. If you have a lot of memory you might want to increase the amount allocated.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
I want to make in C# something as the following structure in C:
struct {
short int i1:2;
short int i2:4;
short int i3:1;
short int i4:9;
} My_struct;
Drot
|
|
|
|
|
AFAIK, there is no support for that type of structure in C#. You can do some hacking with bytes and properties to kinda get that experience.
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
|
Use FlagsAttribute to make bit fields
[Flags]
public enum States:long
{
B_0000 = 0,
B_0001 = 1,
B_0010 = 2,
B_0100 = 4,
B_1000 = 8
}
DevIntelligence.com - My blog for .Net Developers
|
|
|
|
|
Hi, i try to add data from an Access-database to an ArrayList, so far so good, but something goes wrong, can someone help me...??
public List<cd> cdListe = new List<cd>();
public FyldListe()
{
string dbForbindelse = "provider=Microsoft.Jet.OLEDB.4.0; " + "data
source = C:\\databasenavn.mdb";
string HentAlleData = "SELECT nr, art, model, årgang, navn FROM
oversigt";
OleDbDataAdapter DataAdapter = new OleDbDataAdapter(HentAlleData,
dbForbindelse);
DataSet Datasæt = new DataSet();
DataAdapter.Fill(Datasæt, "oversigt");
DataTable dataTable = Datasæt.Tables[0];
foreach (DataRow dataRow in dataTable.Rows)
{
cdListe.Add(new Kamp(dataRow["nr"], dataRow["art"],
dataRow["model"], dataRow["årgang"]));
}
If i, instead of the last line, write:
listBox1.Items.Add(dataRow["nr"], dataRow["art"], dataRow["model"],
dataRow["årgang"]);
..everything add fine to the listBox.
But the other dosen't work, it say's, that it could not convert from
object to string, and .ToString doesn't help...
what do i do wrong...??
I use visual basic express 2005
(hope u can read my english)
Helge
|
|
|
|
|
I would think it is the Kamp constructor.
I assume the constructor looks something like that:
public Kamp(string nr, string art, srting model, string argang){
}
This means that if you call this constructor you need to pass 4 string parameters, but dataRow["xxx"] returns only an object.
If my constructor assumption is correct you'll need something like that:
cdListe.Add(new Kamp(Convert.ToString(dataRow["nr"]),
Convert.ToString(dataRow["art"]),
Convert.ToString(dataRow["model"]),
Convert.ToString(dataRow["årgang"])));
Duif wrote: I use visual basic express 2005
No you are obviously using Visual C# Express...
|
|
|
|
|
Hi Robert, thank you for the fast reply...,
i will try it immediately...
And of course you are rigth, i use visual studio C# express...
Helge
|
|
|
|
|
Hi Robert, it worked...., i'm happy...
Thank you..., have a nice week-end...
Helge
|
|
|
|
|
Hi again Robert, can you also tell me, how i get the data from the ArrayList added to a DataGridView....???
I thought, that i could do it in the DataGridView properties, datasource...
Helge
|
|
|
|
|
Depends a little bit on how you bound your data but here are two alternatives:
string nr = (string)_entriesGridView[2, 3].Value;
ArrayList list = (ArrayList)_entriesGridView.DataSource;
Kamp kamp = (Kamp)list[2];
string nr = Kamp.Nr;
|
|
|
|
|
Hi
I have created a ListView, with View put to Details.
Added a few items, and gave them some subItems.
Then I changed the background colour on all the
items and subItems.
Then when I click on one item it the background on the
first subitem gets gray, and the other subitems get
a white background.
Is it possible to make all the subitems the same colour,
when the item is selected?
Thanks
QzRz
|
|
|
|