English 中文(简体)
新电子邮件锁定前景, 强制将电子邮件窗口作为顶端
原标题:new email locks outlook, forces email window as topMost

我使用以下代码从 DataGridView 读取电子邮件地址, 然后创建 Outlook 电子邮件。 这非常有效, 除了新电子邮件被设置为顶部和/或打开为对话框窗口, 意思是当新电子邮件窗口打开时, 我无法点击 Outlook 或做其他任何工作 。 如果我打开了我的新电子邮件, 我正试图搜索或查看我的收件箱中的东西, 这有问题 。 另外, 在我关闭或发送电子邮件之前, 我的应用程序不会回复( 被锁定 ) 。

是否有办法创建新的电子邮件, 并且仍然允许正常功能? 如果我点击 Outlook 本身的新电子邮件按钮, 我就可以有尽可能多的这些打开, 使用搜索等 。

this.TopMost=假 行是为了隐藏我的 WinForms 应用程序并在前面显示新的电子邮件窗口 。

try
{

      string emailString = resultsGrid[resultsGrid.Columns["Email"].Index, resultsGrid.SelectedCells[resultsGrid.Columns["Email"].Index].RowIndex].Value.ToString();

    if(emailString.Contains("mailto:"))
    {
        emailString = emailString.Replace("mailto:", "");
    }

    this.TopMost = false;

    // Create the Outlook application by using inline initialization.
    Outlook.Application oApp = new Outlook.Application();

    //Create the new message by using the simplest approach.
    Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
    oMsg.Subject = "";
    oMsg.To = emailString;
    oMsg.Body = "";
    oMsg.Display(true);


    oMsg = null;
    oApp = null;
}
catch (Exception ex)
{
    MessageBox.Show(string.Format("An error occurred: {0}", ex.Message));
}

同样奇怪的是,如果我在电子邮件中写一些东西并关闭它, 我可以保存它。 如果我这样做, 当我打开电子邮件后, 它返回到它的锁定状态。 我开始觉得这与电子邮件是如何创建的有关, 所以某些设置或属性正在被应用并保存 。

最佳回答

尝试替换此行 :

oMsg.Display(true);

...与:

oMsg.Display(false);

http://msdn.microsoft.com/en-us/library/ff8618533.aspx" rel="noreferr"\\code>MailTrounds.display 文档,参数的名称为 Modal ,应注明为:

True 来制造窗口模式。 默认值为 False

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签