Welcome our webmaster and SEO forum
Please enjoy the forum, contribute what you can, and wind up the Moderators!
Results 1 to 8 of 8

Thread: Ripping data from emails and placing it into a database

  1. #1
    OldWelshGuy's Avatar
    OldWelshGuy is offline Super Moderator
    Join Date
    Oct 2004
    Posts
    1,998

    Default Ripping data from emails and placing it into a database

    Ripping data from emails and placing it into a database, how hard is this?

    I have just under 1000 emails and want them entered into a list that I can then email.

    Anythoughts? or anyone want to take the job on for peanuts? Here are the fields

    name:
    postcode:
    Address1:
    Adress2:
    Address3:
    Dateofbankruptcy:
    Dateofbankruptcyyear:
    telephone:
    DOB:
    emailapp1:
    empstatus:
    Selfemptradename:
    selfemplength:
    TRadeadd:
    TRadeadd2:
    tradeaddpcode:

  2. #2
    temi's Avatar
    temi is offline Facilitator
    Join Date
    Jun 2003
    Location
    London, England.
    Posts
    10,303

    Default

    You can get someone to write you a simple script that will extract the info for you.

    * Comprehensive UK Web Directory List . eCommerce software UK
    * BossCart.com can build you a.
    Register your domain names at Velnet
    ::
    Add Eco sites to The Green Directory free of charge.
    Use LBS Free PHP Directory Script . Web Hosting Blog

  3. #3
    OldWelshGuy's Avatar
    OldWelshGuy is offline Super Moderator
    Join Date
    Oct 2004
    Posts
    1,998

    Default

    Aye, that was what I meant. so presumably you just save the emails in a folder and run the script on the folder right?

  4. #4
    temi's Avatar
    temi is offline Facilitator
    Join Date
    Jun 2003
    Location
    London, England.
    Posts
    10,303

    Default

    Yes,
    I will ask one of my guys if its something that can be created withing 2-3 hours, if yes, I will get him to create it for you. He is offline now, I will ask him when he gets online tomorrow.

    * Comprehensive UK Web Directory List . eCommerce software UK
    * BossCart.com can build you a.
    Register your domain names at Velnet
    ::
    Add Eco sites to The Green Directory free of charge.
    Use LBS Free PHP Directory Script . Web Hosting Blog

  5. #5
    Humous is offline Member
    Join Date
    May 2007
    Posts
    43

    Default

    I was messing around with doing this a while ago.

    3 problems though
    1 - I didn't finish the project
    2 - I had trouble dealing with different types of email (MIME, RTF, text), I'm not even sure what half of them are.
    3 - It's in perl, which is fine if you have a linux box

    To nab the data I used this function:

    Code:
    sub getmail
    {
    my ($pop, $num_mesg, $i, @messages, @matrix);
    my ($msgfrom,$msgbody,$msgsubject);
    
    $pop = new Mail::POP3Client (   USER => "test",
                                    PASSWORD => "test",
                                    HOST => "mailserver" );
    
    
    $num_mesg = $pop->Count;
    
    
    for ($i = 1; $i <= $pop->Count(); $i++) {
            foreach($pop->Head($i))
            {
            $msgfrom = $_ if /^(From)/;
            $msgsubject = $_ if /^(Subject)/;
            }
    
            $msgbody = $pop->Body($i);
            
            push (@messages, [$msgfrom,$msgsubject,$msgbody]);
    		
    	#$pop->Delete($i);
    
      }
    
    
    
    $pop->Close();
    #print "\n\n";
    return @messages;
    }
    you would then need to either search for keywords or organise line by line (depending on how the email is generated).

    I used a [5] (or any number) in the subject field to allocate the message to a job id, if it didn't exist I created a new job.

    Here's everything else (really messy programmer, it was new to me at the time)
    Code:
    for($i=0;$i<$msgcount;$i++)
    	{
    	
    	($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time);
    	if(length($Month) < 2){$Month = "0".$Month;}
    	if(length($Day) < 2){$Day = "0".$Day;}
    	if(length($Hour) < 2){$Hour = "0".$Hour;}
    	if(length($Minute) < 2){$Minute = "0".$Minute;}
    	if(length($Second) < 2){$Second = "0".$Second;}
    	$Year+=1900;
    	$Month++;
    	$nowtime = qq~$Year$Month$Day$Hour$Minute$Second~;
    	
    	$openb = index($msgdata[$i][1],"[");
    	$closeb = index($msgdata[$i][1],"]");
    
    	$email1 = index($msgdata[$i][0],"<");
    	$email2 = index($msgdata[$i][0],">");
    	$emailaddr = substr($msgdata[$i][0],$email1+1,$email2-$email1-1);
    	
    	$sql=qq~SELECT id,email1 FROM extusers WHERE email1="$emailaddr"~;
    	@tmpary=&getspdata($sql);
    	$tmpusrid=$tmpary[0][0];
    
    		if(index($msgdata[$i][1],"[") > 0)
    		{
    		$idstat="";
    		$subid = substr($msgdata[$i][1],$openb+1,$closeb-$openb-1);
    		}else{
    		$idstat="New";
    		$sql=qq~INSERT INTO job_track(job_source,job_desc,created,altered,user_id) VALUES("Email","$msgdata[$i][1]\n$msgdata[$i][2]","$nowtime","$nowtime","$tmpusrid")~;
    		&putspdata($sql);
    		$sql=qq~SELECT id,created FROM job_track WHERE created="$nowtime"~;
    		@tmpary=&getspdata($sql);
    		$subid=$tmpary[0][0];
    		}
    		
    		if(index($msgdata[$i][2],"Content-Type: text/plain") > 0)
    		{
    		$extracttype="RTF/HTML";
    		$bodystr=index($msgdata[$i][2],"<body>");
    		$bodyend=index($msgdata[$i][2],"</body>");
    		$extractbody=substr($msgdata[$i][2],$bodystr+1,$bodyend-$bodystr-1);
    		}else{
    		$extracttype="Plain text";
    		$extractbody = $msgdata[$i][2];
    		}
    		
    	$shortbody = substr($msgdata[$i][2],0,100)."...";
    	$pibody .= qq~
    	From:$msgdata[$i][0]<br>
    	Email:$emailaddr<br><br>
    	Subject:$msgdata[$i][1]<br>
    	Job ID:$idstat $subid<br>
    	Type:$extracttype<br>
    	Body:$msgdata[$i][2]<br><br>
    	limitedbody:[$bodystr][$bodyend]<br>$extractbody<br><br>
    	~;
    	
    		$sql=qq~INSERT INTO job_incomming(mailfrom,subject,message,job,date,user,type) VALUES("$msgdata[$i][0]","$msgdata[$i][1]","$msgdata[$i][2]","$subid","$nowtime","$tmpusrid","Email")~;
    		&putspdata($sql);
    	
    	}
    hope it helps a little

    Humous

  6. #6
    temi's Avatar
    temi is offline Facilitator
    Join Date
    Jun 2003
    Location
    London, England.
    Posts
    10,303

    Default

    Humous, thanks for the code, rep added. I hope OWG find it useful, I did send him and email saying I can get it sorted for him but he never resplied to my PM

    * Comprehensive UK Web Directory List . eCommerce software UK
    * BossCart.com can build you a.
    Register your domain names at Velnet
    ::
    Add Eco sites to The Green Directory free of charge.
    Use LBS Free PHP Directory Script . Web Hosting Blog

  7. #7
    OldWelshGuy's Avatar
    OldWelshGuy is offline Super Moderator
    Join Date
    Oct 2004
    Posts
    1,998

    Default

    Thanks both.

    temi , sorry I didn't reply, I am not feeling too well at all, so have hardly been online this weekend. :-(

  8. #8
    temi's Avatar
    temi is offline Facilitator
    Join Date
    Jun 2003
    Location
    London, England.
    Posts
    10,303

    Default

    Quote Originally Posted by OldWelshGuy View Post
    Thanks both.

    temi , sorry I didn't reply, I am not feeling too well at all, so have hardly been online this weekend. :-(
    Sorry to hear you are not well James, I have been sneezing like mad too (Hayfever)

    * Comprehensive UK Web Directory List . eCommerce software UK
    * BossCart.com can build you a.
    Register your domain names at Velnet
    ::
    Add Eco sites to The Green Directory free of charge.
    Use LBS Free PHP Directory Script . Web Hosting Blog

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 12-06-2007, 07:50 PM
  2. Is CJ ripping me off?
    By Eric in forum General Webmaster Talk
    Replies: 9
    Last Post: 08-17-2007, 10:05 PM
  3. How to backup my emails ?
    By Threader in forum Computer and Software Forum
    Replies: 2
    Last Post: 05-02-2007, 08:43 AM
  4. adsense for emails! UK!
    By PrivateInvestigator in forum General Webmaster Talk
    Replies: 2
    Last Post: 12-07-2005, 04:41 AM
  5. Placing images with the products
    By goose in forum iG Shop
    Replies: 4
    Last Post: 11-25-2005, 01:23 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124