nsComponentManager::RegisterComponent(kMimeURLUtilsCID,  NULL, NULL, MIME_DLL, PR_FALSE, PR_FALSE);
int main(int argc, char *argv[]) {   nsIMsgCompFields *pMsgCompFields;  nsIMsgSend *pMsgSend;  nsresult rv = NS_OK;  //nsIAppShellService* appShell = nsnull;	nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);	nsComponentManager::RegisterComponent(kEventQueueCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);	nsComponentManager::RegisterComponent(kPrefCID, nsnull, nsnull, PREF_DLL, PR_TRUE, PR_TRUE);	nsComponentManager::RegisterComponent(kFileLocatorCID,  NULL, NS_FILELOCATOR_PROGID, APPSHELL_DLL, PR_TRUE, PR_TRUE);	nsComponentManager::RegisterComponent(kMimeURLUtilsCID,  NULL, NULL, MIME_DLL, PR_FALSE, PR_FALSE);	nsComponentManager::RegisterComponent(kNetSupportDialogCID,  NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE);	nsComponentManager::RegisterComponent(kAppShellServiceCID,  NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE);  SetupRegistry();    // Create the Event Queue for this thread...  NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &rv);   if (NS_FAILED(rv))   {    printf("Failed to get event queue\n");    return rv;  }    rv = pEventQService->CreateThreadEventQueue();  if (NS_FAILED(rv))   {    printf("Failed to create event queue\n");    return rv;  }    // make sure prefs get initialized and loaded..  // mscott - this is just a bad bad bad hack right now until prefs  // has the ability to take nsnull as a parameter. Once that happens,  // prefs will do the work of figuring out which prefs file to load...  NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);   if (NS_FAILED(rv) || (prefs == nsnull))   {    exit(rv);  }    if (NS_FAILED(prefs->StartUp()))  {    printf("Failed to start up prefs!\n");    exit(rv);  }  if (NS_FAILED(prefs->ReadUserPrefs()))  {    printf("Failed on reading user prefs!\n");    exit(rv);  }      nsIMsgIdentity *identity;  identity = GetHackIdentity();  SendOperationListener *sendListener = nsnull;    rv = nsComponentManager::CreateInstance(kMsgSendCID, NULL, nsCOMTypeInfo<nsIMsgSend>::GetIID(), (void **) &pMsgSend);   if (NS_SUCCEEDED(rv) && pMsgSend)   {     printf("We succesfully obtained a nsIMsgSend interface....\n");        rv = nsComponentManager::CreateInstance(kMsgCompFieldsCID, NULL, nsCOMTypeInfo<nsIMsgCompFields>::GetIID(),       (void **) &pMsgCompFields);     if (NS_SUCCEEDED(rv) && pMsgCompFields)    {       char  *aEmail = nsnull;      PRUnichar  *aFullName = nsnull;      char  addr[256];      char  subject[256];      identity->GetEmail(&aEmail);      identity->GetFullName(&aFullName);      PR_snprintf(addr, sizeof(addr), "%s <%s>", aFullName, aEmail);      PR_FREEIF(aEmail);      PR_FREEIF(aFullName);            pMsgCompFields->SetFrom(nsAutoString(addr).GetUnicode());      pMsgCompFields->SetTo(nsAutoString("rhp@netscape.com").GetUnicode());      PR_snprintf(subject, sizeof(subject), "Spam from: %s", addr);      pMsgCompFields->SetSubject(nsAutoString(subject).GetUnicode());      // pMsgCompFields->SetTheForcePlainText(PR_TRUE, &rv);      pMsgCompFields->SetBody(nsAutoString(email).GetUnicode());      pMsgCompFields->SetCharacterSet(nsAutoString("us-ascii").GetUnicode());            pMsgCompFields->SetAttachments(nsAutoString("http://www.netscape.com").GetUnicode());      PRInt32 nBodyLength;      PRUnichar    *pUnicharBody;      char    *pBody;            pMsgCompFields->GetBody(&pUnicharBody);      pBody =  nsAutoString(pUnicharBody).ToNewCString();      if (pBody)        nBodyLength = PL_strlen(pBody);      else        nBodyLength = 0;            nsMsgAttachedFile *localPtr= NULL;      nsMsgAttachmentData *remotePtr = NULL;                  localPtr = GetLocalAttachments();      remotePtr = GetRemoteAttachments();            sendListener = new SendOperationListener();      if (!sendListener)      {        printf("Failure creating send listener!\n");        return NS_ERROR_FAILURE;      }      NS_ADDREF(sendListener);      pMsgSend->AddListener(sendListener);      pMsgSend->CreateAndSendMessage( nsnull,   // No MHTML from here....                                      identity,                                      pMsgCompFields,                                       PR_FALSE,         // PRBool                            digest_p,                                      PR_FALSE,         // PRBool                            dont_deliver_p,                                      nsMsgDeliverNow,  // nsMsgDeliverMode                  mode,                                      nsnull,           // nsIMessage *msgToReplace                                      TEXT_HTML,        // const char                        *attachment1_type,                                      pBody,            // const char                        *attachment1_body,                                      nBodyLength,      // PRUint32                          attachment1_body_length,                                      remotePtr,        // const struct nsMsgAttachmentData   *attachments,                                      localPtr,         // const struct nsMsgAttachedFile     *preloaded_attachments,                                      NULL,             // nsMsgSendPart                     *relatedPart,                                      nsnull);          // listener array            PR_FREEIF(localPtr);      PR_FREEIF(remotePtr);    }      }  #ifdef XP_PC  printf("Sitting in an event processing loop ...Hit Cntl-C to exit...");  while (keepOnRunning)  {    MSG msg;    if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))    {      TranslateMessage(&msg);      DispatchMessage(&msg);    }  }#endif    NS_RELEASE(sendListener);  printf("Releasing the interfaces now...\n");  pMsgSend->Release();   pMsgCompFields->Release();     return 0; }