2

I want to move my email from a somewhat unreliable provider (let's say X) to Gmail. Unfortunately email provider doesn't allow folder export or direct IMAP link.

The only thing I can do is connect Gmail to X via POP3, so that anything in X's inbox gets copied to Gmail.

This I have set up, and it works, but of course POP3 only scans inbox.

I have thousands of emails in other folders than inbox, so I need to move them to inbox first. However, I can only move messages via X's web GUI, which only allows moving one page of messages per turn.

So I have to open Saved messages folder, click on "Select all", select "inbox" and click on "Move", then the page will reload and I need to do this again... hundreds of times.

I made a Javascript function (assume MoveToInbox()) which simulates these actions, and I opened page in Firefox and started Firefox Scratchpad. So, I can keep pressing Ctrl+R in Scratchpad, then wait for page reload, then press it again, which saves about 50% of time.

However, I am wondering, if I can somehow make Scratchpad work with that tab so that it waits for page reload, then executes script then waits again, eliminating all the manual repetitive tasks.

I thought I could somehow do it with window.addEventListener, but this object seems to get cleared on page reload, so is there something I could use instead?

Gnudiff
  • 4,297
  • 1
  • 24
  • 25
  • Perhaps look at another solution http://superuser.com/questions/387493/download-all-mail-messages-from-gmail-including-sent-folder-items – mplungjan Oct 03 '12 at 11:07
  • Thank you, but the point is that there provider X doesn't provide IMAP connection, so I can not link it to Gmail, neither by enabling Gmail's IMAP, nor provider's. – Gnudiff Oct 04 '12 at 06:40

2 Answers2

0

My own quick answer is only by using a Firefox addon such as GreaseMonkey.

The solution will, of course, vary in different cases, but my own was this GreaseMonkey Javascript:

// the function to select all messages and programmatically click on 
// move button:
function moveToInbox()
{
    selectAllCheckbox=document.getElementById("messagesForm")[0]; 
    mailboxSelector=document.getElementsByName('targetMailbox')[0];
    selectAllCheckbox.click(); // click on "select all" checkbox
    mailboxSelector.selectedIndex=1; //specify that we are moving to inbox
    inx.mail.mailbox.mailboxTransfer(); // execute provider's function for moving mail.
}

// This gets executed on any page that matches URL specified in Greasemonkey script properties
// I have put this to execute, if the URL is for the folder I want to move messages from.

messageList=document.getElementById("messagesForm")[0];
// in my case, if there are no more messages to move, the form is not created at all, so 
// I can check for its existance, to determine if I need to execute moving.
if (messageList == null)
{
    return;
}
else
{
    moveToInbox();
}
Gnudiff
  • 4,297
  • 1
  • 24
  • 25
0

Using an iFrame

The first problem is that variables and functions get lost after reloading:
-Use an <iframe> with src = "X"
Now the Cross domain policy is causing troubles:
-Make the <iframe> on the same website as the src

Then, you can easily access and manipulate the website with iframeId.contentDocument

An example:

Navigate to google.com, use Inspect Element to add an iframe:
<iframe src="https://www.google.ae" id="someID"> </iframe>
Then, you can use JavaScript to do anything with the iframe:
someID.contentDocument.location.reload(); setTimeout('someID.contentDocument.getElementById('lst-ib').value="iframes rock"',1000); //You should use something better than setTimeout to wait for the website to load.

Stefnotch
  • 511
  • 2
  • 13
  • 26
  • Thank you; I did this 3 years ago and unfortunately can't recall many details. I do remember I used GreaseMonkey as the previous answer suggested, but I can hardly test your solution now as I am doing completely different things. Hope your answer helps somebody else. – Gnudiff Nov 09 '15 at 14:01