Méthode IFsrmSetting ::EmailTest (fsrm.h)
Envoyez un e-mail à l’adresse e-mail spécifiée.
Syntaxe
HRESULT EmailTest(
[in] BSTR mailTo
);
Paramètres
[in] mailTo
Adresse e-mail. La chaîne est limitée à 255 caractères.
Valeur retournée
La méthode retourne les codes de retour suivants :
Remarques
Utilisez cette méthode pour tester le serveur SMTP spécifié dans la propriété SmtpServer . L’expéditeur est spécifié dans la propriété MailFrom (ne peut pas être défini sur « [Administration Email] »).
L’objet et le corps du message sont du texte prédéfini et localisé.
Exemples
L'exemple suivant illustre l'appel à la méthode.
#ifndef UNICODE
#define UNICODE
#endif
#include <windows.h>
#include <stdio.h>
#include <comutil.h>
#include <fsrm.h> // FSRM base objects and collections
#include <fsrmtlb_i.c> // contains CLSIDs
//
// Call the IFsrmSetting::EmailTest method to test the SMTP email server.
//
void wmain(void)
{
HRESULT hr = 0;
IFsrmSetting* pSettings = NULL;
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if (FAILED(hr))
{
wprintf(L"CoInitializeEx() failed, 0x%x.\n", hr);
exit(1);
}
hr = CoCreateInstance(CLSID_FsrmSetting,
NULL,
CLSCTX_LOCAL_SERVER,
__uuidof(IFsrmSetting),
reinterpret_cast<void**> (&pSettings));
if (FAILED(hr))
{
wprintf(L"CoCreateInstance(FsrmSetting) failed, 0x%x.\n", hr);
if (E_ACCESSDENIED == hr)
wprintf(L"Access denied. You must run the client with an elevated token.\n");
goto cleanup;
}
wprintf(L"Successfully created Setting object.\n");
// Specify the SMTP server to use for sending email.
hr = pSettings->put_SmtpServer(_bstr_t(L"<FQDNOFSMTPSERVER>"));
if (FAILED(hr))
{
wprintf(L"pSettings->put_SmtpServer failed, 0x%x.\n", hr);
goto cleanup;
}
// Test the specified SMTP server. If the test succeeds, you will find a
// predefined email message in C:\Inetpub\mailroot\Drop. You can use
// Outlook Express to read the message.
hr = pSettings->EmailTest(_bstr_t(L"admin@<FQDNOFSMTPSERVER>"));
if (FAILED(hr))
{
wprintf(L"pSettings->EmailTest failed, 0x%x.\n", hr);
goto cleanup;
}
wprintf(L"Successfully sent mail.\n");
cleanup:
if (pSettings)
pSettings->Release();
CoUninitialize();
}
Configuration requise
Condition requise | Valeur |
---|---|
Client minimal pris en charge | Aucun pris en charge |
Serveur minimal pris en charge | Windows Server 2008 |
Plateforme cible | Windows |
En-tête | fsrm.h (inclure FsrmQuota.h, FsrmReports.h, FsrmScreen.h) |
DLL | SrmSvc.dll |