返回我的电子邮件地址Vb.net / outlook 2010应用程序

时间:2015-08-14 10:15:00

标签: vb.net outlook

我正在构建一个VB.net应用程序。 我想检查outlook中的电子邮件地址以进行身份​​验证。

我从以下代码开始:

class Csvreader {

var $fields;            /** columns names retrieved after parsing */ 
var $separator = ';';    /** separator used to explode each line */
var $enclosure = '"';    /** enclosure used to decorate each field */

var $max_row_size = 20000;    /** maximum row size to be used for decoding */

function parse_file($p_Filepath) {

    $file = fopen($p_Filepath, 'r');
    $this->fields = fgetcsv($file, $this->max_row_size, $this->separator, $this->enclosure);
    $keys_values = explode(',',$this->fields[0]);

    $data_keys = array("column 1", "column 2", "column 3"); /// just improvised

    $content    =   array();
    $keys   =   $data_keys;

    $i  =   1;
    while( ($row = fgetcsv($file, $this->max_row_size, $this->separator, $this->enclosure)) != false ) {            
        if( $row != null ) { // skip empty lines
            $values =   explode(',',$row[0]);
            if(count($keys) == count($values)){
                $arr    =   array();
                $new_values =   array();
                $new_values =   $this->escape_string($values);
                for($j=0;$j<count($keys);$j++){
                    if($keys[$j] != ""){
                        $arr[$keys[$j]] =   $new_values[$j];
                    }
                }

                $content[$i]=   $arr;
                $i++;
            }
        }
    }
    fclose($file);
    return $content;
    }
}

function escape_string($data){
    $result =   array();
    foreach($data as $row){
        $result[]   =   str_replace('"', '',$row);
    }
    return $result;
}   
}

我应该怎么做才能返回我的电子邮件地址(知道我在执行期间打开了Outlook)。

提前致谢

2 个答案:

答案 0 :(得分:0)

我认为以下可能会做你想要的:

Dim objOL as Outlook.Application 
Set objOL = New Outlook.Application

Dim email As String = objOL.Session.CurrentUser.AddressEntry.Address

有关详细信息,请参阅:https://msdn.microsoft.com/en-us/library/office/ff184601.aspx

答案 1 :(得分:0)

这个对我有用:

objOL.Session.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress