nsresult rv = NS_OK; nsCOMPtr <nsIMsgMessageService> messageService; rv = GetMessageServiceFromURI(aMessageUri, getter_AddRefs(messageService)); if (messageService) { rv = messageService->OpenAttachment(aContentType, aDisplayName, aUrl, aMessageUri, mDocShell, mMsgWindow, nsnull); }
nsresult rv = NS_ERROR_FAILURE; char *unescapedUrl = nsnull; nsIMsgMessageService * messageService = nsnull;  if (url) { #ifdef DEBUG_MESSENGER printf("nsMessenger::OpenAttachment(%s)\n",url); #endif unescapedUrl = PL_strdup(url); if (unescapedUrl) { nsUnescape(unescapedUrl);  nsCOMPtr<nsIFileSpec> aSpec; nsCOMPtr<nsIFileSpecWithUI> fileSpec(getter_AddRefs(NS_CreateFileSpecWithUI()));  if (!fileSpec) goto done;  rv = fileSpec->ChooseOutputFile("Save Attachment", displayName, nsIFileSpecWithUI::eAllFiles); if (NS_FAILED(rv)) goto done;  aSpec = do_QueryInterface(fileSpec, &rv); if (NS_FAILED(rv)) goto done;  nsSaveAsListener *aListener = new nsSaveAsListener(aSpec); if (aListener) { NS_ADDREF(aListener); nsCOMPtr<nsIURI> aURL;  nsString urlString = unescapedUrl; char *urlCString = urlString.ToNewCString(); rv = CreateStartupUrl(urlCString, getter_AddRefs(aURL)); nsCRT::free(urlCString); if (NS_FAILED(rv)) { NS_RELEASE(aListener); goto done; } aListener->m_channel = null_nsCOMPtr(); NS_WITH_SERVICE(nsIIOService, netService, kIOServiceCID, &rv); rv = netService->NewInputStreamChannel(aURL, nsnull, -1, nsnull, nsnull, getter_AddRefs(aListener->m_channel)); nsAutoString from, to; from = "message/rfc822"; to = "text/xul"; NS_WITH_SERVICE(nsIStreamConverterService, streamConverterService, kIStreamConverterServiceCID, &rv); nsCOMPtr<nsISupports> channelSupport = do_QueryInterface(aListener->m_channel); nsCOMPtr<nsIStreamListener> convertedListener; rv = streamConverterService->AsyncConvertData( from.GetUnicode(), to.GetUnicode(), aListener, channelSupport, getter_AddRefs(convertedListener));  rv = GetMessageServiceFromURI(messageUri, &messageService);  if (NS_SUCCEEDED(rv) && messageService) { rv = messageService->DisplayMessage(messageUri, convertedListener, nsnull, nsnull); } } else { rv = NS_ERROR_OUT_OF_MEMORY; } } else { rv =  NS_ERROR_OUT_OF_MEMORY; } } done: if (messageService) ReleaseMessageServiceFromURI(unescapedUrl, messageService); PR_FREEIF(unescapedUrl);
nsMessenger::OpenAttachment(const char * aContentType, const char * aUrl, const                            char * aDisplayName, const char * aMessageUri){  nsresult rv = NS_OK;  nsCOMPtr <nsIMsgMessageService> messageService;  rv = GetMessageServiceFromURI(aMessageUri, getter_AddRefs(messageService));  if (messageService)  {    rv = messageService->OpenAttachment(aContentType, aDisplayName, aUrl, aMessageUri, mDocShell, mMsgWindow, nsnull);  }	return rv;}