![](/img/trans.png)
[英]How to open default mail client(for e.g outlook) with attachment in java
[英]Java: Open default mail client
我有一個定期解析我的收件箱的軟件。 程序的功能取決於運行的默認郵件程序。
如何從Java中啟動默認郵件程序?
我知道您可以通過使用Desktop
類來實現此目的:
Desktop.getDesktop().mail()
但是除了啟動默認的郵件客戶端外,它還會打開一個我不需要的新電子郵件窗口。
如何在不打開“撰寫新電子郵件”窗口的情況下打開默認郵件客戶端?
編輯:我現在嘗試使用以下代碼片段自行提取信息: http : //support.microsoft.com/kb/180233/zh-cn,但由於此代碼無法編譯(像大多數的Microsoft代碼片段一樣) ,當您不是C ++開發人員,只需要一些代碼時,這真的很糟糕),因為它缺少對&lpProfileTable
的引用。 丟失的代碼將如何顯示?
這是MSDN示例的外觀:
#define UNICODE
#define _UNICODE
#define STRICT
#include <windows.h>
#include <mapix.h>
#include <iostream>
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hinstPrev,
LPSTR lpCmdLine, int nShowCmd) {
// Get a IProfAdmin Interface.
LPPROFADMIN lpProfAdmin;
HRESULT hr = MAPIAdminProfiles(0, &lpProfAdmin);
// Get the Table of Profiles
LPMAPITABLE lpProfileTable;
hr = lpProfAdmin->GetProfileTable(0, &lpProfileTable);
// Build a restriction where PR_DEFAULT_PROFILE = TRUE
SPropValue spvDefaultProfile;
spvDefaultProfile.ulPropTag = PR_DEFAULT_PROFILE;
spvDefaultProfile.Value.b = TRUE;
SRestriction sres;
sres.rt = RES_PROPERTY;
sres.res.resProperty.relop = RELOP_EQ;
sres.res.resProperty.ulPropTag = PR_DEFAULT_PROFILE;
sres.res.resProperty.lpProp = &spvDefaultProfile;
hr = lpProfileTable->Restrict(&sres, TBL_BATCH);
hr = lpProfileTable->FindRow(&sres, BOOKMARK_BEGINNING, 0);
LPSRowSet pRow = NULL;
hr = lpProfileTable->QueryRows(1, 0, &pRow);
// We have a match
if (SUCCEEDED(hr)) {
LPSTR lpDisplayName = pRow->aRow[0].lpProps[0].Value.lpszA;
std::cout << lpDisplayName;
}
}
它在g ++下編譯,但是我不知道如何鏈接可執行文件...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.