posts - 12,comments - 1,trackbacks - 0

        在利用Outlook com组件编程的时候发现,Outlook中接受的邮件的发件人的Email地址不能正确的获得,他的属性里面只有一个SenderName属性,(ol2003之前的版本).而网上的解决办法大多使用CDO。而且大部分代码使用VB写,迁移到csharp不知道如何去做。
郁闷了几个小时之后,终于找到了一个简单有效的解决版本。
具体做法是利用MailItem接口的replay()方法。得到reply后的mail对象,再从这个对象的Recipients获得Address,这个Address就是发件人的Email地址了。
具体的Csharp代码如下:
               MSOutlook.MailItem replymail = olmail.Reply();
                MSOutlook.Recipients rec = replymail.Recipients;
                string from = string.Empty;
                for (int i = 1; i <= rec.Count; i++) {
                    from += rec[i].Address + ";";
                }
               Track.WriteLine(from.Substring(0, from.Length - 1));

posted @ 2007-08-16 11:27 何东建 阅读(320) 评论(1) 编辑

IsolatedStorageFile是MS推出的用来安全存储应用程序信息的一种安全方式。是信息持久化的理想的存储方式。
HashTable可以存储任意可以序列化的实例。So,如果将两种方式结合,就可以持久化任何可以序列化的实例到硬盘上面,而且是很安全。
 [Serializable]
    public class ApplicationStorage : Hashtable {
        #region Private fields

        // File name. Let us use the entry assembly name with .dat as the extension.
        private string settingsFileName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name + ".dat";

        #endregion

        #region Constructor

        // The default constructor.
        public ApplicationStorage() {
            LoadData();
        }

        // This constructor is required for deserializing our class from persistent storage.
        protected ApplicationStorage(SerializationInfo info, StreamingContext context)
            : base(info, context) {
        }

        #endregion

        #region Private methods

        private void LoadData() {
            IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);
            if (isoStore.GetFileNames(settingsFileName).Length == 0) {
                // File not exists. Let us NOT try to DeSerialize it.
                return;
            }

            // Read the stream from Isolated Storage.
            Stream stream = new IsolatedStorageFileStream(settingsFileName, FileMode.OpenOrCreate, isoStore);
            if (stream != null) {
                try {
                    // DeSerialize the Hashtable from stream.
                    IFormatter formatter = new BinaryFormatter();
                    Hashtable appData = (Hashtable)formatter.Deserialize(stream);

                    // Enumerate through the collection and load our base Hashtable.
                    IDictionaryEnumerator enumerator = appData.GetEnumerator();
                    while (enumerator.MoveNext()) {
                        this[enumerator.Key] = enumerator.Value;
                    }
                }
                finally {
                    // We are done with it.
                    stream.Close();
                }
            }
        }

        #endregion

        #region Public Methods

        public void ReLoad() {
            LoadData();
        }

        /// <summary>
        /// Saves the configuration data to the persistent storage.
        /// </summary>
        public void Save() {
            // Open the stream from the IsolatedStorage.
            IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);
            Stream stream = new IsolatedStorageFileStream(settingsFileName, FileMode.Create, isoStore);

            if (stream != null) {
                try {
                    // Serialize the Hashtable into the IsolatedStorage.
                    IFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(stream, (Hashtable)this);
                }
                finally {
                    stream.Close();
                }
            }
        }

        #endregion
    }
该类集成hashtable,因此拥有Hashtable 的功能,该类的两个重要方法,一个是Load 一个是Save。一个是将流序列化成对象,一个是将对象序列化为流。
用法如下:
            ApplicationStorage storage = new ApplicationStorage();
            if (storage["Key1"] != null) {
                object ht = storage[Key1];
                if (ht != null) {
                       ...
                    }
                }
其实就像hashtable 一样用啦!

posted @ 2007-07-18 17:48 何东建 阅读(824) 评论(0) 编辑

1. After you. 你先请。
这是一句很常用的客套话,在进/出门,上车得场合你都可以表现一下。

2. I just couldn't help it. 我就是忍不住。
想想看,这样一个漂亮的句子可用于多少个场合?下面是随意举的一个例子:
I was deeply moved by the film and I cried and cried. I just couldn't help it.

3. Don't take it to heart. 别往心里去,别为此而忧虑伤神。
生活实例:This test isn't that important. Don't take it to heart. 

4. We'd better be off. 我们该走了。It's getting late. We'd better be off . 

5. Let's face it. 面对现实吧。常表明说话人不愿意逃避困难的现状。
参考例句:I know it's a difficult situation. Let's face it, OK? 

6. Let's get started. 咱们开始干吧。
劝导别人时说:Don't just talk. Let's get started. 

7. I'm really dead. 我真要累死了。
坦诚自己的感受时说:After all that work, I'm really dead. 

8. I've done my best. 我已尽力了。

9. Is that so? 真是那样吗?常用在一个人听了一件事后表示惊讶、怀疑。

10. Don't play games with me! 别跟我耍花招!

11. I don't know for sure. 我不确切知道。例如:
Stranger:Could you tell me how to get to the town hall? 
Tom:I don't know for sure. Maybe you could ask the policeman over there. 

12. I'm not going to kid you. 我不是跟你开玩笑的。 例如:
Karin:You quit the job? You are kidding.
 Jack:I'm not going to kid you. I'm serious. 

13. That's something. 太好了,太棒了。例如:
A:I'm granted a full scholarship for this semester. 
B:Congratulations. That's something.

14. Brilliant idea! 这主意真棒!这主意真高明! 

15. Do you really mean it? 此话当真?例如:
Michael:Whenever you are short of money, just come to me. 
David:Do you really mean it? 

16. You are a great help. 你帮了大忙。

17. I couldn't be more sure. 我再也肯定不过。 

18. I am behind you. 我支持你。
 Whatever decision you're going to make, I am behind you. 

19. I'm broke. 我身无分文。

20. Mind you! 请注意!听着!(也可仅用Mind。) 
模范例句:Mind you! He's a very nice fellow though bad-tempered. 

21. You can count on it. 你尽管相信好了,尽管放心。例如:
A:Do you think he will come to my birthday party? 
B:You can count on it. 

22. I never liked it anyway. 我一直不太喜欢这东西。
当朋友或同事不小心摔坏你的东西时就可以用上这句话给他一个台阶,打破尴尬局面:Oh, don't worry. I'm thinking of buying a new one. I never liked it anyway. 

23. That depends. 看情况再说。例如:
I may go to the airport to meet her. But that depends. 

24. Congratulations. 恭喜你,祝贺你。

25. Thanks anyway. 无论如何我还是得谢谢你。当别人尽力要帮助你却没帮成时,你就可以用这个短语表示谢意。

26. It's a deal. 一言为定。
Harry:Haven't seen you for ages. Let's have a get-together next week. 
Jenny:It's a deal.

posted @ 2007-07-09 10:52 何东建 阅读(30) 评论(0) 编辑
Life doesn't always give the joys we want,
We don't always get our hopes and dreams ,And we don't always get our own way,
but Don't give up ,because you can make a difference one situation and one person at a time.
生活并非总是如你所愿。
希望有时会落空,梦想有时会破灭,我们不能一切随心所愿。
但别放弃希望,因为事物并非一成不变;不同时间,不同场合,你会呈现不同的面貌。

You are suppose to buy a rose in such a pink atomosphere,
I wonder if the rose bloom only for us
在如此浪漫的氛围里,
注定你要买一束玫瑰;
只是我怀疑它们
为我们还是为自己开放。
With a little money,
I hold the rose's destination.
When the day passes,
who else will care her petals pales somewhere else?
只用了一点点钱,
我握着一束玫瑰的命运。
情人节过后,
谁还会叹息她的花瓣
在哪里凋谢?

posted @ 2007-07-03 09:19 何东建 阅读(49) 评论(0) 编辑

在写oba项目的时候,以前一直考虑的实体类中忽略了拥有子类的情况,该子类可能是很多类共用的。
例如:
class B {
        private int x;
        public int X {
            get { return x; }
            set { x = value; }
        }
    }
class A {
        private B _b;
        public B b {
            get { return _b; }
            set { _b = value; }
        }
    }
这种情况下:如果我得到一个A的实例a,(假定当获得a实例的时候b肯定不为null)我想给该实例的a.b.X利用反射进行赋值。实际编写如下:
static void SetValue(Object obj, string str, object value) {
            object temp = obj;
            object key = null;
            PropertyInfo values = null;
            string[] strs = str.Split('.');
            int length = strs.Length;
            if (length > 1) {
                for (int i = 0; i < length; i++) {
                    key = temp;
                    PropertyInfo propinfo = temp.GetType().GetProperty(strs[i]);
                    object o = temp.GetType().InvokeMember(strs[i], BindingFlags.GetProperty, null, temp, null);
                    if (o == null) {
                        return;
                    }
                    temp = o;
                    if (i == length - 2) {
                        values = propinfo;
                    }
                }
            }
            else {
            }
           values.SetValue(key, value, null);
        }
TestDriven:
static void Main(string[] args) {
            A a = new A();
            B b = new B();
            b.X = 1000;
            a.b = b;

            Type t = a.GetType();
            PropertyInfo propinfo=t.GetProperty("b");

            object o = t.InvokeMember("b", BindingFlags.GetProperty, null, a, null);

            if (o != null) {
                PropertyInfo propinfo2 = o.GetType().GetProperty("X");
                propinfo2.SetValue(o, 1000000, null);
                propinfo.SetValue(a, o, null);
            }
            SetValue(a, "b.X", 1233);
            Console.Write(a.b.X);
            Console.ReadLine();            
        }
最后得到该需求的通用写法。

posted @ 2007-07-02 17:40 何东建 阅读(317) 评论(0) 编辑
摘要: 在Outlook中存在不同的域对象MailItem ,ContactItem,TaskItem,AppointmentItem,NoteItem...这些类都是继承ItemEvents_10_Event接口的。而且这些类里面都有EntryID,UserProperties,ItemProperties,Parent,Class,这些属性,都实现了Save(),Delete(),Display()方...阅读全文
posted @ 2007-06-29 10:53 何东建 阅读(119) 评论(0) 编辑
摘要: 最近在完成一个OBA的项目使用VSTO+outlook sp1 开发,然而一直遇到下面的问题,MS并没有在Outlook 2003中增加一个去掉该对话框的界面。做outlook与我们系统集成如果不停的跳出这种界面对用户来说是一个很不好的用户体验。MS给出的解释是:Outlook 2003 provides the Object Model Guard security feature, which...阅读全文
posted @ 2007-06-25 16:38 何东建 阅读(54) 评论(0) 编辑
摘要: 在webservice程序中用到EventLog写入事件日志的一段代码。但是一直会出现权限的问题。Event code: 4010 Event message: An unhandled security exception has occurred. Event time: 2007-6-1 13:22:26 Event time (UTC): 2007-6-1 5:22:26 Event ID...阅读全文
posted @ 2007-06-01 13:45 何东建 阅读(510) 评论(0) 编辑
摘要: 我们经常在用vs2005做项目的时候会把一个项目分成几个模块(不管是对于功能上,还是系统构架上面),为的是以后部署,还有修改维护时候的方便。这样就会带来一个问题,随着模块的增加(这里所说得每个模块就是指每个项目),我们如果依赖IDE的话,每次都得从源代码管理器读取最新得版本,进行编译。然而IDE加载得时候会加载很多必须得文件,这样就大大浪费了时间。再有就是我们不能一次都把这些项目都编译了。我们不得...阅读全文
posted @ 2007-04-10 11:31 何东建 阅读(589) 评论(0) 编辑
摘要: 1.类和结构之间的选择: 首先了解值类型和引用类型在行为上的差异(引用类型在堆上分配,有垃圾收集器(GC)管理,而值类型要么在栈上面分配并在栈展开的时候释放,要么内联在容纳它的类型中并在容纳它的类型中被释放时释放.因此,与引用类型的分配与释放开销更低.引用类型的数组是非内联的,也就是说数组的元素只是一些引用,指向那些位于堆中的引用类型的实例.而值类型的数组是内联的.也就是数组的元素就是值类型的真正...阅读全文
posted @ 2006-12-10 21:09 何东建 阅读(183) 评论(0) 编辑
仅列出标题  下一页