Get attachment name without downloading the whole message - asp.net

I do not find a way to get attachment file name without downloading the whole message using OpenPop.Net
The Pop3Client.GetMessageHeaders do not expose any data about attachments. The Pop3Client.GetMessage(messageNumber) gives attachment data but first download the whole message.
Maybe someone know how to do that?

I am the main developer for OpenPop.Net.
If you take a look at the RFC for POP3 you will notice that it is not possible to get information about attachments. To get the message headers, OpenPop.Net current sends the TOP <messagenumber> 0 command to receive headers.
Since attachment headers are located deep inside the message body, I cannot see how any POP3 client should accomplish your requirement.
IMAP is another protocol, and it includes features which allows the IMAP client to get information about each part inside a message. You might want to go in that direction.

Related

How to read the attachment file from a mail in WSO2?

How I can get the attachment from a mail in WSO2 ? I able to get the subject and body of the mail. I need to fetch an attachment file in the mail. How it could be done ? I'm using Gmail POP3 server.
There is nothing specific whether the mail is from some WSO2 server or not. If you have attachments, that implies the mail uses multipart/form. Therefore you can process it as a multipart/form message. There are a lot of libraries that you can use to do the parsing. e.g. Apache Commons, Javamail or you can use normal java URL connection and carefully work with the mime boundaries.
We used to parse the whole message body looking for boundries of attachments, then apply Base64Decode to substracted pieces, then operate with them like binaries.
Sorry, I do not have that synapse-config right now, can not tell you exactly what to do.

Detecting if a URL is a file download

How can I detect if a given URL is a file to be downloaded?
I came across the content-disposition header, however it seems that this isn't a part of http 1.1 directly.
Is there a more standard way to detect if the response for a GET request made to a given URL is actually a file to/can be downloaded?
That is the response is not html or json or anything similar, but something like an image, mp3, pdf file etc.?
HTTP is a transfer protocol - which is a very different thing to hard drive storage layouts. The concept of "file" simply does not exist in HTTP. No more than your computer hard drive contains actual paper-and-cardboard "files" that one would see in an office filing system.
Whatever you may think the HTTP message or URL are saying the response content does not have to come from any computer file, and does not have to be stored in one by the recipient.
The response to any GET message in HTTP can always be "downloaded" by sending another GET request with that same URL (and maybe other headers in the case of HTTP/1.1 variants). That is built into the definition of what a GET message is and has nothing to do with files.
I ended up using the content-type to decide if it's an html file or some other type of file that is on the other end of a given URL.
I'm using the content-disposition header content to detect the original file name if it exists since the header isn't available everywhere.
Could checking for a file extension be a possibility? Sorry I can't enlarge on that much without knowing more, but I guess you could consider using PHP to implement this if HTML doesn't have enough functionality?

How can I find the URL that downloads a file?

I am developing a web scraper and I need to download a .pdf file from a page. I can get the file name from the html tag, but can't find the complete url (or request body) that downloads the file.
I have tried to sniff the traffic with the chrome and firefox network traffic tool and with wireshark, with no success. I can see it make a post request to the exact same url as the page itself, and so I can't understand why this happens. My guess is that the filename is being sent inside the POST request body, but I also can't find that information in those tools. If I could see the variable name in the body, I could create a copy of the request and then get the file.
How can I get that information?
Here is the website I am talking about: http://www2.trt8.jus.br/consultaprocesso/formulario/ProcessoConjulgado.aspx?sDsTelaOrigem=ListarProcessos.aspx&iNrInstancia=1&sFlTipo=T&iNrProcessoVaraUnica=126&iNrProcessoUnica=1267&iNrProcessoAnoUnica=2010&iNrRegiaoUnica=8&iNrJusticaUnica=5&iNrDigitoUnica=24&iNrProcesso=1267&iNrProcessoAno=2010&iNrProcesso2a=0&iNrProcessoAno2a=0
EDIT: for those seeking to do something similar, take a look at this website: http://curl.trillworks.com/
It converts a cURL to a python requests code. Very useful
The POST data used for the request is encoded content generated by ASP.NET. It contains various state/session information of the page that the link is on. This makes it difficult to directly scrape for the URL.
You can examine the HAR by exporting it from the Network tab in Chrome DevTools:
The __EVENTVALIDATION data is used to ensure events raised on the client originate from the controls rendered on the page from the server.
You might be able to achieve what you want by requesting the page the link is on first, then extract the required POST data from the response (containing the page state and embedded request for file), and then make a new request with this information. This assumes the server doesn't expire any sessions in the meantime.

Sending email attachment

I need to send a pdf file received from SFTP with an email as an attachment. I am just looking if this can be done without using custom pipeline component. Can this be done only with SMTP send port configuration. How can this be approached
In your orchestration your Out message must be modified like below. You must give your file list with pipe delimited list.
MessageOut(SMTP.Attachments) = "C:\\temp\atachment1.pdf|C:\\temp\atachment2.pdf";

Logging into a webpage via HTTP Request

So I have a webpage, ("http://data.terapeak.com/verify/") and I don't see any & tags in the URL so I am unaware how to post data to this. I need to do this via HTTPRequest rather than browser control. I am creating a double threaded batch searching program. I have already successfully made this using a single browser control but that wont allow for multi-threading, atleast with my current knowledge due to the fact that even when creating a new frmBrw that already exists it needs for me to set the threat apartment to single. If i set it to single, I am unable to have it send the data the the excel sheet I need both threads to access. I hope this is clear... The basic question is how can I log into this form via HTTP request.
This isn't going to be easy to answer without further details however I suspect you'll need to provide the variables via a HTTP POST request.
Can you successfully login to this page in your browser? If so, run a proxy tool such as fiddler and check the HTTP headers it makes to the server. You should see the form variables being passed over. You then need to mimic this in code.
How to: Send Data Using the WebRequest Class
Hope this gets you started

Resources