|
Hi,
I want to develop C# application using Windows Live Mail "MAPI".
kindly give me method / samples link
Thank you
(Riaz)
|
|
|
|
|
This is something I had written (or may be copied) long ago. Not even sure if this works but surely gives something to you to start with:
class SendMail
{
#region Constants
private const string sSubject = "You got spammed!";
#endregion
#region Variables
List<MapiRecipDesc> aoRecipients = new List<MapiRecipDesc>();
#endregion
#region Classes
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class MapiMessage
{
public int iReserved;
public string sSubject;
public string sNoteText;
public string sMessageType;
public string sDateReceived;
public string sConversationID;
public int iFlags;
public IntPtr oOriginator;
public int iRecipCount;
public IntPtr oRecips;
public int iFileCount;
public IntPtr iFiles;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class MapiRecipDesc
{
public int iReserved;
public int iRecipClass;
public string sName;
public string sAddress;
public int iIDSize;
public IntPtr iEntryID;
}
#endregion
#region Constructors
public SendMail()
{
MapiMessage oMsg = new MapiMessage();
oMsg.sSubject = sSubject;
MapiRecipDesc recipient = new MapiRecipDesc();
recipient.iRecipClass = 1;
recipient.sName = "mail_id";
aoRecipients.Add(recipient);
oMsg.oRecips = GetRecipients(out oMsg.iRecipCount);
int iError = MAPISendMail(new IntPtr(0), new IntPtr(0), oMsg, 9, 0);
}
#endregion
#region Methods
[DllImport("Mapi32.dll")]
static extern int MAPISendMail(IntPtr oSess, IntPtr oHwnd, MapiMessage sMsg, int iFlag, int iRsv);
IntPtr GetRecipients(out int iReciCount)
{
iReciCount = 0;
if (aoRecipients.Count == 0)
return IntPtr.Zero;
int iSize = Marshal.SizeOf(typeof(MapiRecipDesc));
IntPtr oIntPtr = Marshal.AllocHGlobal(aoRecipients.Count * iSize);
int iPtr = (int)oIntPtr;
foreach (MapiRecipDesc oReciDesc in aoRecipients)
{
Marshal.StructureToPtr(oReciDesc, (IntPtr)iPtr, false);
iPtr += iSize;
}
iReciCount = aoRecipients.Count;
return oIntPtr;
}
#endregion
}
|
|
|
|
|
|
i recently created an app to capture images through webcam in xp and it works fine, but for that i used two interops
1.Interop.WIALib
2.Interop.WIAVIDEOLib
i read some articles saying that wia 2.0 is working with win7 , but it's not working in win7 it gives
"Retrieving the COM class factory for component with CLSID {4EC4272E-2E6F-4EEB-91D0-EBC4D58E8DEE} failed due to the following error: 80040154."
i have already registered the wiaaut.dll using regsvr32 .
having any idea .
thanx in advance.
|
|
|
|
|
I don't know the specific answer to your question, however I have some suggestions:
1.
It could be related to the app running in 64-bit mode while some parts you refer to may have been built for 32-bit; one cannot mix both in a single process.
2.
entering an error code in the Google search box often is quite useful; in your case it gives many results, including this one.[^]
3.
There is at least one CodeProject article[^] on Webcam stuff mentioning the same error code, see the latest question in its forum; unfortunately for you, there isn't a reply yet.
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I know MDI's are supposed to be just containers and they can't have contents other than maybe a menustrip.
But I'd like to have a main window with buttons, images and other stuff, and then smaller windows that open inside it.
Is there any way to make this main form and MDI and get the MDI contents (buttons and everything else) sent to back every time a new form is opened? I tried placing all my main form contents in a panel and then call the panel.sendToBack() method when a new form is opened, but it sends it SO back that it ends up in the back of my screen, even behind the main form
I know an option is to show the forms as modal dialogs, but I'm supposed to let the user work with more than one window at a time.
Any hints?
Thanks
|
|
|
|
|
Look in your parent form Control collection. You'll find a control of type MdiClient that hosts all of your child windows. You get at it and use it just like any other control from your code, even undock it and resize it. You just can't get at it with the designer. Docs on it are here[^].
|
|
|
|
|
Thanks for the tip
Although I'm not sure about what to do with the MdiClient control once I find it in the collection.
I need to make it stay back while the user works with the child forms. Right now, only the form stays back but the panel inside it stays on top, covering the child forms when they open.
modified on Friday, January 21, 2011 2:21 PM
|
|
|
|
|
You cannot make the MdiClient appear on top of other controls on the parent form. It'll stay behind all other controls on the Mdi Parent form. But, as I said, you can get a reference to the control and undock it and move it over to the side to make room for you other form controls. Something like:
foreach (Control c in this.Controls) {
if (c is MdiClient) {
MdiClient mdic = (MdiClient)c;
mdic.Dock = DockStyle.None;
mdic.Anchor = AnchorStyles.None;
mdic.BackColor = Color.Blue;
mdic.Location = new Point(40, 40);
mdic.Size = new Size(400, 400);
}
}
|
|
|
|
|
If you dock the panel to top, any child form that you open should open over the top or under it in the form container.
|
|
|
|
|
Hi all,
I have a ToolStripMenuItem in my MenuStrip . I've added a few ToolStripMenuItem s as dropdown items at design time. Now I'd like to copy that list of dropdown items to a ToolStripDropDownButton at runtime but I seem to move the items from the ToolStripMenuItem to the ToolStripDropDownButton , not duplicate it.
Here is the code I'm using:
ToolStripItem[] newitems = new ToolStripItem[myToolStripMenuItem.DropDownItems.Count];
myToolStripMenuItem.DropDownItems.CopyTo(newitems, 0);
myToolStripDropDownButton.DropDownItems.AddRange(newitems);
But the problem is that as soon as the last line executes the DropDownItems collection for the ToolStripMenuItem becomes empty. Does anyone have advice for me? Thanks in advance.
|
|
|
|
|
I think your issue is that your array is essentially storing references of each button - so your last line is in effect adding the exact same buttons (and will automatically become a "move")
What you should do is...
- Iterate the existing list of items
- create new items based on the existing ones
- add the new one to where you want them
this should provide a "copy" for you
foreach(ToolStripItem item in myToolStripMenuItem.DropDownItem){
ToolStripItem newItem = new ToolStripItem();
myToolStripDropDownButton.DropDownItems.Add(newItem);
}
return 5;
|
|
|
|
|
First of all, the ToolStripItem() constructor is protected so your first line in the foreach loop is already going to cause a problem. Secondly, it's that comment line of yours that is the big headache. It means I have to copy the event handler, the tooltip text and everything.
Is it a fact that a ToolStripItem can belong to only one DropDownItem collection?
|
|
|
|
|
The code was more for a idea than actual use - I have not worked with them for a while and forget the actual usage but I have created them dynamically is the past so I know you can create an instance somehow.
Again, its been a while so I didn't know if there was a 'clone' type of function perhaps. But considering it is a button surely you will only need to copy a few key values such as Text, Icon (if any) and the Click eventHandler.
ToolStripItem is a Control, and a Control can only have one parent Control - Basically what you have inadvertently ended up doing is changing the parent control - this is why it appears to "Move" (I don't know much about how this happens 'behind the scenes' thou)
return 5;
|
|
|
|
|
Had a little play now.. are your items all the same type? i.e. ToolStripButton as you can create all those controls.
This is pretty messy but just an idea of what I was playing with...
foreach (ToolStripItem item in toolStripDropDownButton1.DropDownItems)
{
ToolStripItem newItem = new ToolStripMenuItem();
if (item is ToolStripComboBox)
newItem = new ToolStripComboBox();
else if (item is ToolStripTextBox)
newItem = new ToolStripTextBox();
newItem.Text = item.Text;
toolStripDropDownButton2.DropDownItems.Add(newItem);
}
return 5;
|
|
|
|
|
Hi
i want to implement deisgner at runTime in my app, to do this i 've create a simple win app and write this code to my form :
public partial class Form1 : Form
{
IServiceContainer isc;
DesignSurface ds;
IDesignerHost idh;
ISelectionService iss;
IToolboxUser itu;
MyToolBox toolbox;
public Form1()
{
isc = new ServiceContainer();
ds = new DesignSurface(isc);
ds.BeginLoad(typeof(Form));
idh = (IDesignerHost)ds.GetService(typeof(IDesignerHost));
iss = (ISelectionService)ds.GetService(typeof(ISelectionService));
itu = (IToolboxUser)idh.GetDesigner(idh.RootComponent);
InitializeComponent();
iss.SelectionChanged += new EventHandler(iss_SelectionChanged);
}
private void Form1_Load(object sender, EventArgs e)
{
toolbox = new MyToolBox();
toolbox.Dock = DockStyle.Fill;
splitContainer1.Panel1.Controls.Add(toolbox);
isc.AddService(typeof(IToolboxService), toolbox);
Control c = ds.View as Control;
c.Parent = this.splitContainer2.Panel1;
c.Dock = DockStyle.Fill;
}
private void iss_SelectionChanged(object sender, EventArgs e)
{
propertyGrid1.SelectedObject = iss.PrimarySelection;
}
}
and also create a new class named 'ToolboxServiceImp' which inherits from ListBox and IToolboxService as follow :
Please download my sample app from http://cid-1490cc59dd735cbf.office.live.com/self.aspx/.Public/Designer2.rar
my problem is that, at runTime when i drag & drop a control from my toolbox on the form, i got this error :
Error
---------------------------
Unable to cast object of type 'System.RuntimeType' to type 'System.Drawing.Design.ToolboxItem'.
---------------------------
OK
also, when i click on form, i got this error and designer become corrupt :
Error
---------------------------
The control System.Windows.Forms.Form has thrown an unhandled exception in the designer and has been disabled.
Exception:
Unable to cast object of type 'System.RuntimeType' to type 'System.Drawing.Design.ToolboxItem'.
Stack trace:
---------------------------
OK
where is my problem and how to solve it ?
thanks in advance
|
|
|
|
|
I don't plan to download your app, but I can guess that somewhere in your code you are trying to cast some object to a ToolboxItem , that does not have that class in its object hierarchy. You need to create the object of the correct type first.
I must get a clever new signature for 2011.
|
|
|
|
|
|
hdv212 wrote: do u have problem to download from this link ?
Firstly, I do not download from external links. Secondly, I cannot unpack .rar files.
hdv212 wrote: i found several example and source codes to demonstrate this, but all of them create a some new classes and write more complex code.
I don't know what your experience level is, but mine is nowhere good enough to advise on the Microsoft sample.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi
do u have problem to download my sample file ?
do u have live account ?
|
|
|
|
|
No to both questions. But as I said above, I don't have anything else to suggest to you.
I must get a clever new signature for 2011.
|
|
|
|
|
If you are interested in this sort of thing, you might want to look at the source for SharpDevelop[^] to see how they do it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
|
|
|
|
|
|
hdv212 wrote: all of them create a some new classes and write more complex code.
It is a complex topic.
If you are looking for some simpler implementations, then maybe look at things like UML designers or Flow Chart designers. There are a fair few of those out there.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
|
|
|
|
|
Hi!!
i'm getting this error when i try to share screen from my notebook connected to the router using wifi n my pc by ethernet
"System.ArgumentException: Value does not fall within the expected range.
at RDPCOMAPILib.IRDPSRAPIViewer.Connect(String bstrConnectionString, String bstrName, String bstrPassword)
at AxRDPCOMAPILib.AxRDPViewer.Connect(String bstrConnectionString, String bstrName, String bstrPassword)"
this error comes each time i try to connect it
axRDPviewer.connect(Connstring,"user1", "");
I cant get this corrected...
It works perfect when i do it on my pc
but aint working when try to share my notebook screen...
the Connstring is being sent by Tcp message(Send and receive)...
Can u tell me where is the source of the problem... How can i take care of this???
|
|
|
|