Condividi tramite


Metodo IFsrmSetting::EmailTest (fsrm.h)

Inviare un messaggio di posta elettronica all'indirizzo di posta elettronica specificato.

Sintassi

HRESULT EmailTest(
  [in] BSTR mailTo
);

Parametri

[in] mailTo

Indirizzo e-mail. La stringa è limitata a 255 caratteri.

Valore restituito

Il metodo restituisce i codici restituiti seguenti:

Commenti

Usare questo metodo per testare il server SMTP specificato nella proprietà SmtpServer . Il mittente viene specificato nella proprietà MailFrom (non può essere impostato su "[Amministrazione Email]").

Il corpo del soggetto e del messaggio è predefinito, localizzato.

Esempio

Nell'esempio seguente viene illustrato come chiamare questo metodo.

#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();
}

Requisiti

Requisito Valore
Client minimo supportato Nessuno supportato
Server minimo supportato Windows Server 2008
Piattaforma di destinazione Windows
Intestazione fsrm.h (include FsrmQuota.h, FsrmReports.h, FsrmScreen.h)
DLL SrmSvc.dll

Vedi anche

FsrmSetting

IFsrmSetting