[PHP and mySQL]Emails to outlook

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
Have you ever wanted to import the emails from your site to your outlook. Like if you are running a newsletter and want to use outlook to send the letter. Here is an easy way to export all emails into outlook:

Create a php file with this:

PHP:
<?php
// set database server access variables:
$host = "localhost";
$user = "USERNAME";
$pass = "PASSWORD";
$db = "DATABASE"; 

// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); 

// select database
mysql_select_db($db) or die ("Unable to select database!"); 

// create query
$query = "SELECT * FROM FIELD";

// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 

// see if any rows were returned
if (mysql_num_rows($result) > 0) {
    // yes
    // print them one after another
    while($row = mysql_fetch_row($result)) {
        echo "".$row[0].";<br />";
    }
}
else {
    // no
    // print status message
    echo "No rows found!";
}

// free result set memory
mysql_free_result($result);

// close connection
mysql_close($connection);  
?>

Edit USERNAME, PASSWORD, DATABASE and FIELD (// create query
$query = "SELECT * FROM FIELD";).

ALSO:
PHP:
echo "".$row[0].";<br />";
change the 0 to the row with the emails. If the row with emails is row 3 (example), change the 0 to a 4. 0 is the first row, 1 is the second, 2 is the third and so on

this is gonna echo a list like this

mail@mail.tld;
mail2@mail2.tld;
/.../

Copy this into a text document.
Now open outlook and choose import>other adressbook.
Then choose "textdocument".
Done!

I am pretty sure this will work because it worked for me.
 
Top