社区
C#
帖子详情
使用Outlook的COM模块,对profile的logon方法有问题,不能正确登陆指定的profile,感觉只是对最后一次登陆的profile进行操作,不知为何?
sitnc
2008-11-28 02:23:22
使用Outlook的COM模块,对profile的logon方法有问题,不能正确登陆指定的profile,感觉只是对最后一次登陆的profile进行操作,不知为何?
...全文
69
4
打赏
收藏
使用Outlook的COM模块,对profile的logon方法有问题,不能正确登陆指定的profile,感觉只是对最后一次登陆的profile进行操作,不知为何?
使用Outlook的COM模块,对profile的logon方法有问题,不能正确登陆指定的profile,感觉只是对最后一次登陆的profile进行操作,不知为何?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
sitnc
2008-11-28
打赏
举报
回复
to feiyun0112:谢谢你的回复。
这个连接好像对应我的另一个有关发信的问题,可是这个方案是outlook 2007的,我的环境是2003的,不知道还有没有别的办法,谢谢!
sitnc
2008-11-28
打赏
举报
回复
To qinhl99: 谢谢你的回复。
我使用的就是类似你给连接中的logon的方法,我遇到的问题时这样的。比如:有两个outlook的profile,一个是exchange,一个是hotmail,手动启动outlook,选择exchange profile,然后关闭outlook,用outlook的COM接口logon登陆(logon("hotmail", "password", true, ture))hotmail profile,然后创建一个contacts,但是发现这个contacts不是创建在hotmail的profile下,而且仍然创建在exchange的profile下,感觉logon方法没有起到作用
feiyun0112
2008-11-28
打赏
举报
回复
http://msdn.microsoft.com/en-us/library/bb207787.aspx
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)
http://feiyun0112.cnblogs.com/
qinhl99
2008-11-28
打赏
举报
回复
http://www.microsoft.com/china/technet/community/scriptcenter/resources/officetips/jun05/tips0614.mspx
Sending Email using MAPI - A
COM
DLL(sending email demo and soucecode)
Introduction During the software development, I have seen many applications that requires incorporating email support. I remember, once I was to develop an application, which sends emails at the specific time to specific people with the customized messages. For that I developed a
COM
service that used MAPI. MAPI, i.e. Messaging Application Programming Interface, is the standard messaging architecture and a
com
plete set of functions and object-oriented interfaces. Here I have an Email
com
ponent, a
COM
DLL, which is a set of messaging functions that helps you create messaging-enabled applications. This
COM
com
ponent uses Simple MAPI to achieve that. Note: MAPI is used by various industry-standard e-mail clients, such as the Microsoft Exchange client, all versions of Microsoft
Outlook
and
Outlook
Express, including QUAL
COM
M Incorporated (Eudora) and Netscape
Com
munications Corporation. So you can use this
com
ponent with these client applications also.
Com
ponent Design The CLSID of the Email
com
ponent is CLSID_Mail and it has only one interface IMail with the interface ID IID_IMail. CMail is the implementation class and contains following data members: m_MAPI
Log
on Function pointer for MAPI
Log
on m_MAPISendMail Function pointer for MAPISendMail m_MAPISendDocuments Function pointer for MAPISendDocuments m_MAPIFindNext Function pointer for MAPIFindNext m_MAPIReadMail Function pointer for MAPIReadMail m_MAPIResolveName Function pointer for MAPIResolveName m_MAPIAddress Function pointer for MAPIAddress m_MAPI
Log
off Function pointer for MAPI
Log
off m_MAPIFreeBuffer Function pointer for MAPIFreeBuffer m_MAPIDetails Function pointer for MAPIDetails m_MAPISaveMail Function pointer for MAPISaveMail IMail have the following functions: IsMapiInstalled Checks if the MAPI is installed on the system. It searches Win.INI file for the MAPI key. If found it returns S_OK. InitMapi After checking the through IsMapiInstalled, it initializes the MAPI function pointers. Method should be called once before using the
com
ponent. put_str
Profile
Name Takes the name of the
outlook
profile
name you are using to send the email. put_strEmailAddress Sets the recipient email address. You can specify more than one
com
ma (,) separated recipient addresses. put_strRecipient Sets the name you want to specify for the recipients, sets the email names of the sender – it may be different from your specified
profile
email address. put_strSubject Sets the subject of the email. get_strSubject Returns the email subject. put_strMessage Sets email message text. get_strMessage Returns message text. put_strAttachmentFilePath Sets the email attachment with the full path like “c:\abc.txt”. get_strAttachmentFilePath Returns the path of email attachment. put_strAttachmentFile The display name of the attachment (Sample.txt), by default, it’s the same as that specified in put_strAttachmentFilePath. get_strAttachmentFile Returns the attachment file name.
Log
on Opens a new
log
on session if not already opened, using specified
outlook
profile
, name and the
profile
password, you must
log
on before sending the email. I have set password to NULL assuming that the
profile
you will specify have NO password, but you can specify your own password. Automatically called by Send method.
Log
off
Log
s off, and closes the session. Automatically called by Send method after sending the email. Send Sends the email, requires valid
outlook
profile
name, recipient email address and a
log
in session to send email. Steps to execute the demo project The demo project demonstrates the way you can use the
com
ponent to send an email. In order to execute the demo project, the following settings are required: Step 1: You must have some valid Output Express email account or create one named Test
Profile
. You can create an email
profile
in Express from Tools>Accounts menu. This will open Internet Accounts property sheet. On the tab All, click the button Add and then Mail. A wizard will let you create an email account, specify the valid email address. For hotmail account, wizard automatically sets the names of email servers. After successfully creating the account, select the account name from the list in All tab (for hotmail account, the default account name is Hotmail). Open account properties by pressing Properties button and change the account name from default name (say Hotmail) to Test
Profile
. Step 2: Register the DLL All
COM
DLLs required to be registered. After copying the DLL source code, you can register the DLL by right clicking the DLL and selecting Register DLL or Register
COM
com
ponent option, or simply by double clicking the DLL.
Com
piling the DLL code in Visual Studio will automatically register the DLL. Step 3:
Log
ged on to the net Make sure you are
log
ged on to the net. If not,
outlook
will fail to deliver the email, however, you can still check the
com
posed email in your outbox. How to send email? After specifying the information in the dia
log
box, click the Send button. A warning message will be displayed, click Send button. Note:The warning dia
log
is displayed because of the security constraints. If you want to get rid of this dia
log
box, then you will have to use Extended MAPI instead of simple MAPI. Here is the method CTestEmailDlg::OnSend method, which is used to pass the user specified information to the email object and call the IMail::Send method after setting everything. Collapse | Copy Code //##//##////////////////////////////////////////////////////////////// /////////////////////////////////////////////// // // void CTestEmailDlg::OnSend() // // This module is called when send button is pressed and uses //Email
COM
DLL to send email - Aisha Ikram // Note: dont forget to initialize
COM
library using CoInitialize(NULL); //##//##//////////////////////////////////////////////////////////////////// /////////////////////////////////////////////// void CTestEmailDlg::OnSend() { UpdateData(); try{ C
Com
Ptr
objMail; HRESULT hr; // make sure the DLL is registered hr = objMail.CoCreateInstance(CLSID_Mail); if(SUCCEEDED(hr)) { if(hr== S_OK) { //
profile
name is
com
pulsory, this is the
outlook
profile
, // i used "
outlook
express" as configuring it is easier than // "MS
outlook
" make sure to specify the correct sender's address // for this
profile
and make sure that
outlook
express is //the default email client. if(m_str
Profile
.IsEmpty()) { AfxMessageBox("Please specify email
profile
name "); return; } if(m_strTo.IsEmpty()) { AfxMessageBox("Please specify recipient's email address "); return; } // by default, it's Test
Profile
, assumes that a
profile
with this //name exists in
outlook
hr= objMail->put_str
Profile
Name((_bstr_t)m_str
Profile
); hr = objMail->put_strSubject((_bstr_t)m_strSubject); // this is the email or set of email addresses (separated by ,) // which is actually used to send email hr = objMail->put_strEmailAddress((_bstr_t)m_strTo); // recipient is just to show the display name hr = objMail->put_strRecipient((_bstr_t)m_strTo); hr = objMail->put_strAttachmentFilePath((_bstr_t)m_strAttachment); hr = objMail->put_strMessage((_bstr_t)m_strMessage); hr= objMail->Send(); if(hr!=S_OK) AfxMessageBox("Error, make sure the info is correct"); }//if } //if } // try catch(...) { AfxMessageBox("Error, make sure specified info is correct"); } } Check the mail in the recipient inbox. Where to use This
com
ponent can be extended to incorporate the functionalities like opening an existing inbox to read emails automatically from the inbox and
com
posing new emails etc. It can be used to send emails automatically with customized user messages and attachments to specific people at particular time, especially while using some exe servers or NT services. That's it. If there is any suggestions or
com
ments you are most wel
com
e. Your rating would help me evaluate the standard of my article.
outlook
邮件模板 python自动编辑_在发送邮件之前
使用
python检测
outlook
自动响应程序...
您必须
使用
Outlook
's automation interface,或者执行与
Outlook
相同的
操作
(大概是通过MAPI或AD),或者对其他API执行相同的
操作
。在您可以
使用
win32
com
作为这三个选项中的第一个。在将收件人添加到
Outlook
的“收件人”列表时,它将获得一个^{}对象,该对象具有一个^{}属性,
Outlook
将向您显示该对象。在通过OOM获取Recipient对象的最简单...
python如何读取web
outlook
内容_用Python通过MAPI读取
Outlook
中的电子邮件
我正在尝试编写一个简短的程序,该程序将读取exchange/
Outlook
配置文件中某个文件夹中电子邮件的内容,以便可以
操作
数据。但是,我在查找有关python和exchange/
Outlook
集成的许多信息时遇到
问题
。很多东西不是很旧/没有文档/没有解释。我试过几个片段,但似乎也有同样的错误。我试过Tim Golden的密码:import win32
com
.clientsession = win...
python自动发邮件
outlook
取消提醒_在发送消息之前
使用
python检测
outlook
自动应答器...
您必须
使用
Outlook
's automation interface,或者执行与
Outlook
相同的
操作
(可能通过MAPI或AD),或
使用
其他API执行等效
操作
。您可以
使用
win32
com
作为三者中的第一个。当您将收件人添加到
Outlook
中的“收件人”列表时,它会获得一个Recipient对象,该对象具有AutoResponse属性,
Outlook
将向您显示该属性。通过OOM获取Recipie...
如何发送一条消息通过
Outlook
对象模型与 VC++
如何发送一条消息通过
Outlook
对象模型与 VC++ 在编译并运行下面的代码之前, 一定要按照给定的任何地方文本"TO DO:"找到。 // Change the path to msoutl85.olb if necessary. #import "C:\\Program Files\\MicrosoftOffice\\Office\\msou
C#
111,130
社区成员
642,542
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章