NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv); if (NS_FAILED(rv)) goto done; nsCOMPtr<nsIRDFResource> res; rv = rdf->GetResource(m_templateUri, getter_AddRefs(res)); if (NS_FAILED(rv)) goto done; nsCOMPtr<nsIMsgFolder> templateFolder; templateFolder = do_QueryInterface(res, &rv); if (NS_FAILED(rv)) goto done; NS_WITH_SERVICE(nsIMsgCopyService, copyService, kMsgCopyServiceCID, &rv); if (NS_FAILED(rv)) goto done; rv = copyService->CopyFileMessage(m_fileSpec, templateFolder, nsnull, PR_TRUE, this, nsnull);
if (m_templateUri) { NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv); if (NS_FAILED(rv)) goto done; nsCOMPtr<nsIRDFResource> res; rv = rdf->GetResource(m_templateUri, getter_AddRefs(res)); if (NS_FAILED(rv)) goto done; nsCOMPtr<nsIMsgFolder> templateFolder; templateFolder = do_QueryInterface(res, &rv); if (NS_FAILED(rv)) goto done; NS_WITH_SERVICE(nsIMsgCopyService, copyService, kMsgCopyServiceCID, &rv); if (NS_FAILED(rv)) goto done; rv = copyService->CopyFileMessage(m_fileSpec, templateFolder, nsnull, PR_TRUE, this, nsnull); killSelf = PR_FALSE; }
nsSaveAsListener::OnStopRunningUrl(nsIURI* url, nsresult exitCode){  nsresult rv = exitCode;  if (m_fileSpec)  {    m_fileSpec->Flush();    m_fileSpec->CloseStream();    if (NS_FAILED(rv)) goto done;    NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);    if (NS_FAILED(rv)) goto done;    nsCOMPtr<nsIRDFResource> res;    rv = rdf->GetResource(m_templateUri, getter_AddRefs(res));    if (NS_FAILED(rv)) goto done;    nsCOMPtr<nsIMsgFolder> templateFolder;    templateFolder = do_QueryInterface(res, &rv);    if (NS_FAILED(rv)) goto done;    NS_WITH_SERVICE(nsIMsgCopyService, copyService, kMsgCopyServiceCID, &rv);    if (NS_FAILED(rv)) goto done;    rv = copyService->CopyFileMessage(m_fileSpec, templateFolder, nsnull,                                      PR_TRUE, this, nsnull);  }done:  if (NS_FAILED(rv))  {    if (m_fileSpec)    {      nsFileSpec realSpec;      m_fileSpec->GetFileSpec(&realSpec);      realSpec.Delete(PR_FALSE);      Release(); // no more work to be done; kill ourself    }  }  return rv;}