如何编程对outlook帐户进行备份,急!!!(100分)

  • 主题发起人 主题发起人 txz123
  • 开始时间 开始时间
T

txz123

Unregistered / Unconfirmed
GUEST, unregistred user!
各位老大,小弟要写一个程序对本机的outlook所有帐户进行导出备份,查了N多资料,不得其解,请帮帮忙指点一二.先谢谢了.
 
据说备份
C:/Documents and Settings/administrator/Local Settings/Application Data/Identities/{不一定字串,不理解意思}/Microsoft/Outlook Express
目录下面的多个文件就可以了!
 
我不是要备份邮件,而是帐户信息,比如说我的outlook express有十多个帐户,我想把这些帐户信息进行备份(outlook下有导出帐户功能,但只能一个一个导).
 
高手帮帮忙
 
没试过,不过你可以采用ole的方式来控制outlook进行帐号导出,其实根操作word差不多。方法可以参考msdn
 
我查了msdn,也许英语水平差,反正没有找到备份帐号的方法.有知道的指点一下.谢了先.
 
我也想知道!帮顶
 
一些资料,我也没试过。。
1。Backup Outlook Attachments
uses
ComObj;

{...}

function ManageAttachments(SendersName, AttachmentPath: string;
MailDelete: Boolean): Boolean;
var
oApp: Variant;
oNs: Variant;
oFolder: Variant;
oMsg: Variant;
AtC: Variant;
AttFilename: Variant;
FileName: string;
CheckSender: string;
Counter: integer;
MailCounter: integer;
begin
try
oApp := CreateOLEObject('outlook.application');
try
oNs := oApp.GetNamespace('MAPI');
ofolder := oNS.GetDefaultFolder(6); // FolderTypeEnum (olFolderInbox)
MailCounter := 1;
// If there is any email in the Inbox
if ofolder.Items.Count > 0 then
begin
repeat
// Get the first Email
oMsg := ofolder.Items(MailCounter);
// Check the name or Email
// Use CheckSender := oMsg.subject to search on Subject;
CheckSender := oMsg.sendername;
if CheckSender = SendersName then
// Remove this line to backup all your attachments.
begin
// Check how many attachments
atc := oMsg.Attachments.Count;
if atc > 0 then
begin
// Get all the attachments and save them
for Counter := 1 to atc do
begin
AttFilename := oMsg.Attachments.item(Counter).FileName;
//filename := IncludeTrailingBackslash(AttachmentPath)+AttFilename; {Use this line for D5)}
FileName := AttachmentPath + '/' + AttFilename;
oMsg.Attachments.Item(Counter).SaveAsFile(FileName);
end;
end;
if MailDelete then
begin
oMsg.Delete;
// There's 1 Email less, so MailCounter - 1
Dec(MailCounter);
end;
end;
// Get the next Email
Inc(MailCounter);
// Do until there is no more Email to check
until MailCounter > ofolder.Items.Count;
end;
finally
oApp.quit;
end;
except
Result := False;
Exit;
end;
Result := True;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
// ManageAttachments(Email or name, Backup directory, MailDelete yes or no)
ManageAttachments('info@cleys.com', 'F:/test', False);
end;


{
Warning!
All your selected Email will be deleted if MailDelete = true

Achtung!
Alle E-Mails werden gelöscht, wenn MailDelete = true ist.
}
2.extract email addresses from Outlook .dbx files
unit ExtractEmailsFunc;

interface

uses
Windows, SysUtils;

procedure CheckEMail(FilePath: string);

implementation

var
BufferSize: Integer;

function VerifyFile(strFileName: string): Integer;
var
intErro: Integer;
tsrFile: TSearchRec;
begin
intErro := FindFirst(strFileName, FaAnyFile, tsrFile);
if intErro = 0 then Result := tsrFile.Size
else
Result := -1;
FindClose(tsrFile);
end;

procedure CheckEMail(FilePath: string);
var
I: Integer;
hFile: Integer;
Buffer: PChar;
StrEmail: string;
begin
hFile := FileOpen(FilePath, fmOpenRead);
try
if hFile = 0 then Exit;
GetMem(Buffer, bufferSize + 1);
ZeroMemory(Buffer, BufferSize + 1);
try
FileRead(hFile, Buffer^, BufferSize);
I := 0;
while I <= BufferSize - 1 do
begin
StrEmail := '';
if Buffer = '<' then
begin
Inc(I);
while (Buffer <> '@') and (I <= BufferSize) do
begin
if (Buffer = CHR(45)) or (Buffer = CHR(46)) or
(Buffer = CHR(90)) or ((Buffer > CHR(49)) and (Buffer <= CHR(57)))
or ((Buffer >= CHR(65)) and (Buffer <= CHR(90))) or
((Buffer >= CHR(97)) and (Buffer <= CHR(122))) then
begin
StrEmail := StrEmail + Buffer;
end
else
begin
StrEmail := '';
Break;
end;
Inc(I);
end;
if StrEmail <> '' then
begin
StrEmail := StrEmail + '@';
Inc(I);
while (Buffer <> '.') and (I <= BufferSize) do
begin
if (Buffer = CHR(45)) or (Buffer = CHR(46)) or
(Buffer = CHR(90)) or ((Buffer >= CHR(49)) and (Buffer <= CHR(57)))
or ((Buffer >= CHR(65)) and (Buffer <= CHR(90))) or
((Buffer >= CHR(97)) and (Buffer <= CHR(122))) then
begin
StrEmail := StrEmail + Buffer;
end
else
begin
StrEmail := '';
Break;
end;
Inc(I);
end;
if StrEmail <> '' then
begin
StrEmail := StrEmail + '.';
Inc(i);
while (Buffer <> '>') and (I <= BufferSize) do
begin
if (Buffer = CHR(45)) or (Buffer = CHR(46)) or
(Buffer = CHR(90)) or ((Buffer >= CHR(49)) and (Buffer <= CHR(57)))
or ((Buffer >= CHR(65)) and (Buffer <= CHR(90))) or
((Buffer >= CHR(97)) and (Buffer <= CHR(122))) then
begin
StrEmail := StrEmail + Buffer;
end
else
begin
StrEmail := '';
Break;
end;
Inc(I);
end;
if StrEmail <> '' then
begin
WriteLn(StrEmail);
Inc(I);
end;
end;
end;
end
else
Inc(I);
end;
finally
FreeMem(Buffer);
end;
finally
FileClose(hFile);
end;
end;

begin
BufferSize := VerifyFile(ParamStr(1));
if BufferSize <= 0 then Exit;
CheckEMail(ParamStr(1));
end.
3。get all outlook contacts
uses ComObj;


procedure TForm1.Button1Click(Sender: TObject);
const
olFolderContacts = $0000000A;
var
outlook, NameSpace, Contacts, Contact: OleVariant;
i: Integer;
begin
outlook := CreateOleObject('Outlook.Application');
NameSpace := outlook.GetNameSpace('MAPI');

Contacts := NameSpace.GetDefaultFolder(olFolderContacts);
for i := 1 to Contacts.Items.Count do
begin
Contact := Contacts.Items.Item(i);
{now you can read any property of contact. For example, full name and
email address}
ShowMessage(Contact.FullName + ' <' + Contact.Email1Address + '>');
end;

Outlook := UnAssigned;
end;

{if you need a birthday, you can retrieve it as DateToStr(Contact.Birthday)

Any contact item have a lot of properties. See a list (alphabet):

Birthday
Business2TelephoneNumber
BusinessAddress
BusinessAddressCity
BusinessAddressCountry
BusinessAddressPostalCode
BusinessAddressPostOfficeBox
BusinessAddressState
BusinessAddressStreet
BusinessFaxNumber
BusinessHomePage
BusinessTelephoneNumber
CompanyAndFullName
CompanyMainTelephoneNumber
CompanyName
ComputerNetworkName
Department
Email1Address
Email1AddressType
Email1DisplayName
Email2Address
Email2AddressType
Email2DisplayName
Email3Address
Email3AddressType
Email3DisplayName
FirstName
FTPSite
FullName
FullNameAndCompany
GovernmentIDNumber
Hobby
Home2TelephoneNumber
HomeAddress
HomeAddressCity
HomeAddressCountry
HomeAddressPostalCode
HomeAddressPostOfficeBox
HomeAddressState
HomeAddressStree
HomeFaxNumber
HomeTelephoneNumber
Initials
ISDNNumber
JobTitle
Language
LastName
LastNameAndFirstName
MailingAddress
MailingAddressCity
MailingAddressCountry
MailingAddressPostalCode
MailingAddressPostOfficeBox
MailingAddressState
MailingAddressStreet
MiddleName
NickName
OfficeLocation
OrganizationalIDNumber
PersonalHomePage
PrimaryTelephoneNumber
Profession
Suffix
Title
WebPage}
4。outlook_addressbook_to_db_table.
ComObj, Outlook_TLB;

procedure TForm1.Button1Click(Sender: TObject);
var
MSOutlook, MyNameSpace, MyFolder, MyItem: Variant;
s: string;
i: Integer;
begin
try
MSOutlook := CreateOleObject('Outlook.Application');
MyNameSpace := MSOutlook.GetNameSpace('MAPI');
MyFolder := MyNamespace.GetDefaultFolder(olFolderContacts);
for i := 1 to MyFolder.Items.Count do
begin
s := s + #13#13'Contact No: ' + IntToStr(i) + #13#13;
MyItem := MyFolder.Items;
s := s + 'BillingInformation: ' + MyItem.BillingInformation + #13;
s := s + 'Body: ' + MyItem.Body + #13;
s := s + 'Categories: ' + MyItem.Categories + #13;
s := s + 'Companies: ' + MyItem.Companies + #13;
s := s + 'CreationTime: ' + DateTimeToStr(MyItem.CreationTime) + #13;
s := s + 'EntryID: ' + MyItem.EntryID + #13;
s := s + 'Importance: ' + IntToStr(MyItem.Importance) + #13;
s := s + 'LastModificationTime: ' + DateTimeToStr(MyItem.LastModificationTime) + #13;
s := s + 'MessageClass: ' + MyItem.MessageClass + #13;
s := s + 'Mileage: ' + MyItem.Mileage + #13;
s := s + 'NoAging: ' + IntToStr(MyItem.NoAging) + #13;
s := s + 'OutlookVersion: ' + MyItem.OutlookVersion + #13;
s := s + 'Saved: ' + IntToStr(MyItem.Saved) + #13;
s := s + 'Sensitivity: ' + IntToStr(MyItem.Sensitivity) + #13;
s := s + 'Size: ' + IntToStr(MyItem.Size) + #13;
s := s + 'Subject: ' + MyItem.Subject + #13;
s := s + 'UnRead: ' + IntToStr(MyItem.UnRead) + #13;
s := s + 'Account: ' + MyItem.Account + #13;
s := s + 'Anniversary: ' + DateTimeToStr(MyItem.Anniversary) + #13;
s := s + 'AssistantName: ' + MyItem.AssistantName + #13;
s := s + 'AssistantTelephoneNumber: ' + MyItem.AssistantTelephoneNumber + #13;
s := s + 'Birthday: ' + DateTimeToStr(MyItem.Birthday) + #13;
s := s + 'Business2TelephoneNumber: ' + MyItem.Business2TelephoneNumber + #13;
s := s + 'BusinessAddress: ' + MyItem.BusinessAddress + #13;
s := s + 'BusinessAddressCity: ' + MyItem.BusinessAddressCity + #13;
s := s + 'BusinessAddressCountry: ' + MyItem.BusinessAddressCountry + #13;
s := s + 'BusinessAddressPostalCode: ' + MyItem.BusinessAddressPostalCode + #13;
s := s + 'BusinessAddressPostOfficeBox: ' + MyItem.BusinessAddressPostOfficeBox + #13;
s := s + 'BusinessAddressState: ' + MyItem.BusinessAddressState + #13;
s := s + 'BusinessAddressStreet: ' + MyItem.BusinessAddressStreet + #13;
s := s + 'BusinessFaxNumber: ' + MyItem.BusinessFaxNumber + #13;
s := s + 'BusinessHomePage: ' + MyItem.BusinessHomePage + #13;
s := s + 'BusinessTelephoneNumber: ' + MyItem.BusinessTelephoneNumber + #13;
s := s + 'CallbackTelephoneNumber: ' + MyItem.CallbackTelephoneNumber + #13;
s := s + 'CarTelephoneNumber: ' + MyItem.CarTelephoneNumber + #13;
s := s + 'Children: ' + MyItem.Children + #13;
s := s + 'CompanyAndFullName: ' + MyItem.CompanyAndFullName + #13;
s := s + 'CompanyMainTelephoneNumber: ' + MyItem.CompanyMainTelephoneNumber + #13;
s := s + 'CompanyName: ' + MyItem.CompanyName + #13;
s := s + 'ComputerNetworkName: ' + MyItem.ComputerNetworkName + #13;
s := s + 'CustomerID: ' + MyItem.CustomerID + #13;
s := s + 'Department: ' + MyItem.Department + #13;
s := s + 'Email1Address: ' + MyItem.Email1Address + #13;
s := s + 'Email1AddressType: ' + MyItem.Email1AddressType + #13;
s := s + 'Email1DisplayName: ' + MyItem.Email1DisplayName + #13;
s := s + 'Email1EntryID: ' + MyItem.Email1EntryID + #13;
s := s + 'Email2Address: ' + MyItem.Email2Address + #13;
s := s + 'Email2AddressType: ' + MyItem.Email2AddressType + #13;
s := s + 'Email2DisplayName: ' + MyItem.Email2DisplayName + #13;
s := s + 'Email2EntryID: ' + MyItem.Email2EntryID + #13;
s := s + 'Email3Address: ' + MyItem.Email3Address + #13;
s := s + 'Email3AddressType: ' + MyItem.Email3AddressType + #13;
s := s + 'Email3DisplayName: ' + MyItem.Email3DisplayName + #13;
s := s + 'Email3EntryID: ' + MyItem.Email3EntryID + #13;
s := s + 'FileAs: ' + MyItem.FileAs + #13;
s := s + 'FirstName: ' + MyItem.FirstName + #13;
s := s + 'FTPSite: ' + MyItem.FTPSite + #13;
s := s + 'FullName: ' + MyItem.FullName + #13;
s := s + 'FullNameAndCompany: ' + MyItem.FullNameAndCompany + #13;
s := s + 'Gender: ' + IntToStr(MyItem.Gender) + #13;
s := s + 'GovernmentIDNumber: ' + MyItem.GovernmentIDNumber + #13;
s := s + 'Hobby: ' + MyItem.Hobby + #13;
s := s + 'Home2TelephoneNumber: ' + MyItem.Home2TelephoneNumber + #13;
s := s + 'HomeAddress: ' + MyItem.HomeAddress + #13;
s := s + 'HomeAddressCity: ' + MyItem.HomeAddressCity + #13;
s := s + 'HomeAddressCountry: ' + MyItem.HomeAddressCountry + #13;
s := s + 'HomeAddressPostalCode: ' + MyItem.HomeAddressPostalCode + #13;
s := s + 'HomeAddressPostOfficeBox: ' + MyItem.HomeAddressPostOfficeBox + #13;
s := s + 'HomeAddressState: ' + MyItem.HomeAddressState + #13;
s := s + 'HomeAddressStreet: ' + MyItem.HomeAddressStreet + #13;
s := s + 'HomeFaxNumber: ' + MyItem.HomeFaxNumber + #13;
s := s + 'HomeTelephoneNumber: ' + MyItem.HomeTelephoneNumber + #13;
s := s + 'Initials: ' + MyItem.Initials + #13;
s := s + 'ISDNNumber: ' + MyItem.ISDNNumber + #13;
s := s + 'JobTitle: ' + MyItem.JobTitle + #13;
s := s + 'Journal: ' + IntToStr(MyItem.Journal) + #13;
s := s + 'Language: ' + MyItem.Language + #13;
s := s + 'LastName: ' + MyItem.LastName + #13;
s := s + 'LastNameAndFirstName: ' + MyItem.LastNameAndFirstName + #13;
s := s + 'MailingAddress: ' + MyItem.MailingAddress + #13;
s := s + 'MailingAddressCity: ' + MyItem.MailingAddressCity + #13;
s := s + 'MailingAddressCountry: ' + MyItem.MailingAddressCountry + #13;
s := s + 'MailingAddressPostalCode: ' + MyItem.MailingAddressPostalCode + #13;
s := s + 'MailingAddressPostOfficeBox: ' + MyItem.MailingAddressPostOfficeBox + #13;
s := s + 'MailingAddressState: ' + MyItem.MailingAddressState + #13;
s := s + 'MailingAddressStreet: ' + MyItem.MailingAddressStreet + #13;
s := s + 'ManagerName: ' + MyItem.ManagerName + #13;
s := s + 'MiddleName: ' + MyItem.MiddleName + #13;
s := s + 'MobileTelephoneNumber: ' + MyItem.MobileTelephoneNumber + #13;
s := s + 'NickName: ' + MyItem.NickName + #13;
s := s + 'OfficeLocation: ' + MyItem.OfficeLocation + #13;
s := s + 'OrganizationalIDNumber: ' + MyItem.OrganizationalIDNumber + #13;
s := s + 'OtherAddress: ' + MyItem.OtherAddress + #13;
s := s + 'OtherAddressCity: ' + MyItem.OtherAddressCity + #13;
s := s + 'OtherAddressCountry: ' + MyItem.OtherAddressCountry + #13;
s := s + 'OtherAddressPostalCode: ' + MyItem.OtherAddressPostalCode + #13;
s := s + 'OtherAddressPostOfficeBox: ' + MyItem.OtherAddressPostOfficeBox + #13;
s := s + 'OtherAddressState: ' + MyItem.OtherAddressState + #13;
s := s + 'OtherAddressStreet: ' + MyItem.OtherAddressStreet + #13;
s := s + 'OtherFaxNumber: ' + MyItem.OtherFaxNumber + #13;
s := s + 'OtherTelephoneNumber: ' + MyItem.OtherTelephoneNumber + #13;
s := s + 'PagerNumber: ' + MyItem.PagerNumber + #13;
s := s + 'PersonalHomePage: ' + MyItem.PersonalHomePage + #13;
s := s + 'PrimaryTelephoneNumber: ' + MyItem.PrimaryTelephoneNumber + #13;
s := s + 'Profession: ' + MyItem.Profession + #13;
s := s + 'RadioTelephoneNumber: ' + MyItem.RadioTelephoneNumber + #13;
s := s + 'ReferredBy: ' + MyItem.ReferredBy + #13;
s := s + 'SelectedMailingAddress: ' + IntToStr(MyItem.SelectedMailingAddress) + #13;
s := s + 'Spouse: ' + MyItem.Spouse + #13;
s := s + 'Suffix: ' + MyItem.Suffix + #13;
s := s + 'TelexNumber: ' + MyItem.TelexNumber + #13;
s := s + 'Title: ' + MyItem.Title + #13;
s := s + 'TTYTDDTelephoneNumber: ' + MyItem.TTYTDDTelephoneNumber + #13;
s := s + 'User1: ' + MyItem.User1 + #13;
s := s + 'User2: ' + MyItem.User2 + #13;
s := s + 'User3: ' + MyItem.User3 + #13;
s := s + 'User4: ' + MyItem.User4 + #13;
s := s + 'UserCertificate: ' + MyItem.UserCertificate + #13;
s := s + 'WebPage: ' + MyItem.WebPage + #13;
end;
Memo1.Lines.Text := s;
except
on E: Exception do
MessageDlg(E.message + #13 + s, mtError, [mbOk], 0);
end;
MSOutlook.Quit;
end;
 
thank jlutt-sadan的回答.但不是我想要的.我只要帐户及口令信息.
 
OUTLOOK可以导出所有的帐户的吧!我重装了两次了都是导出/导入的呀
 
晕,king.gray:我当然知道outlook可以导出帐户,现在我想的是只要帐户及口令信息
 
后退
顶部