单击电子邮件中的对象启动Windows窗体应用程序 [英] Launch Windows Forms App by clicking object in an email

查看:79
本文介绍了单击电子邮件中的对象启动Windows窗体应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

为工程变更管理做的应用。



我需要做的是电子邮件用户一旦改变已经启动,然后每个后续用户批准更改。



我想要的是用户能够点击电子邮件中的内容,这将是启动应用程序,并将更改备注号码传递给应用程序,这样当它打开时,它已经检索了需要他们注意的特定ECN号码的信息。



一个网络应用程序可能是最简单的,然后只是在邮件中添加一个链接,但我以前从未做过网络应用程序,我需要尝试在星期一早上之前完成这个 - 所以这不是一个选项。



正在考虑附加一个带有特定扩展名的文本文件(如* .ecn),其中只包含一行 - ecn编号,然后关联我的应用程序的扩展名。有点像从文件中获取ECN编号,并将其用作命令行参数。



应用程序也必须能够自行打开虽然。



这是一个可行的选择,我怎么能实现这个目标?



谢谢



Richard

Hi
Doing app for Engineering Change Management.

What I need to do is email users once a change has been initiated, and then again as each successive user approves the change.

What I would like is for users to be able to click something in the email, which would launch the app, and pass the Change note Number to the app, so that when it opens, it has already retrieved the info for that specific ECN number that requires their attention.

A web app would probably be the easiest, and then simply put a link in the mail, but I've never done a web app before, and I need to try to complete this before Monday morning - so that is NOT an option.

Was thinking along the lines of attaching a text file with a specific extension (like *.ecn) that contains one line only - the ecn number, and then associating the extension with my app. Sort of like getting the ECN number from the file, and using this as a command line parameter.

The app also has to be able to open on its own as well though.

Is this a viable option, and how could I achieve this?

Thanks

Richard

推荐答案

这可能是最快的选择...



如果做一个Windows窗体应用程序,你可以这样做:



首先,创建一个新的Windows窗体应用程序,然后在Program.cs文件中你可以做



Thats probably the quickest option...

If doing a windows forms application, you can do something like this:

First, create a new Windows Forms application, then in the Program.cs file you can do

static void Main(string[] args)
{
    string ecnNumber = string.empty;
    if (args.Length > 1)
    {
        ecnNumber = System.IO.File.ReadAllText(args[1]);
    }

    //... 

    WhateverYourFormType myForm = new WhateverYourFormType();
    myForm.ECNNumber = ecnNumber;

    Application.Run(myForm);
}

//In your WhateverYourFormType you have...
public class WhateverYourFormType : Form
{
    public string ECNNumber { get; set; }

    public override void OnShown(EventArgs e)
    {
        if (!string.IsNullOrEmpty(ECNNumber))
        {
            //Load your ECN information
        }
    }
}


你好Ron



我已经在表格上做了很多工作。我是否重新开始,或者我是否朝着正确的方向前进:



在program.cs

Hi Ron

I've already done lots of work on the form. Do I start again or am I heading in the right direction here:

In program.cs
namespace ECN_Manager
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {

            string ecnNumber = "";
            if (args.Length > 1)
            {
                ecnNumber = System.IO.File.ReadAllText(args[1]);
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Form1 myForm = new Form1();
            myForm.ECNNumber = ecnNumber; 

            Application.Run(myForm);
        }
    }
}





Form1.cs





In Form1.cs

namespace ECN_Manager
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public string ECNNumber { get; set; }

        public override void OnShown(EventArgs e)    //This is what I edited
        {
            if (!string.IsNullOrEmpty(ECNNumber))
            {
                this.txtECNNo.Text = ECNNumber;
            }
        }

        
    }
}



但收到错误:公开覆盖void OnFormShown(EventArgs e)(找不到覆盖的Siutable方法)



不熟悉C#,但我不能在构造函数中放置可选参数吗?




but getting error on: "public override void OnFormShown(EventArgs e)" (No Siutable method found to Override)

Not that familiar with C#, but could I not put an optional parameter in the constructor?

<pre lang="c#">
 public Form1(optional string ECNNumber)
        {
            InitializeComponent();
        }


这篇关于单击电子邮件中的对象启动Windows窗体应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆