邮件的附件添加问题(100分)

  • 主题发起人 主题发起人 jinzhengang
  • 开始时间 开始时间
J

jinzhengang

Unregistered / Unconfirmed
GUEST, unregistred user!
我想把一张图片通过写程序直接添加到outlook的附件里,而不是在outlook中点击“附件”,
然后通过下拉选择框找到我要发送的图片,再添加到附件中进行发送,那位朋友帮我解决
一下这个难题,谢谢了
 
自已做个OUTLOOK,哈
 
启动outlook并加入附件:
var Outlook : variant;
Item : variant;
xlsFileName:String;
begin
Try
Outlook := CreateOLEObject('Outlook.Application');
try
Item:=Outlook.CreateItem(0);
xlsFileName:=ExtractFilePath(Application.EXEName)+'NHCDAILY.XLS';
Item.Attachments.Add(xlsFileName,1,1,'NHCDAILY.XLS');
xlsFileName:=ExtractFilePath(Application.EXEName)+'BANKS.XLS';
Item.Attachments.Add(xlsFileName,1,1,'BANKS.XLS');
Item.Display(1);
Finally
Update;
Screen.Cursor:=crHourGlass;
Outlook.Quit;
Screen.Cursor:=crDefault;
end;
Except
Showmessage('错误:本机未安装OutLook,或OutLook打开错误!');
End;
end;
 
楼上的不能用
 
除非用OLE绑定,否则,是不能直接对那个东西直接添加附件的。
有这个工夫,你还不如自己写个SMTP的邮件发送呢。
 
procedure SendMail;
var Outlook: variant;
OutlookNameSpace: variant;
OutlookFolder: variant;
OutlookMailItem: variant;
OutlookRecipient: variant;
OutlookAttachment: variant;
begin
try
Outlook:=CreateOleObject('Outlook.Application');
except
Application.MessageBox('无法启动Microsoft Outlook!','错误',MB_OK+MB_ICONERROR);
Exit;
end;
try
OutlookNameSpace := Outlook.GetNamespace('MAPI');
OutlookFolder := OutlookNameSpace.GetDefaultFolder(olFolderOutbox);
OutlookMailItem := OutlookFolder.Items.Add(olMailItem);
OutlookRecipient := OutlookMailItem.Recipients.Add(Trim(frmEmailFile.edtAddr.Text));
OutlookRecipient.Type := olTo;
if not OutlookRecipient.Resolve then
begin
Application.MessageBox('无法解析地址!','错误',MB_OK+MB_ICONERROR);
Exit;
end;
OutlookAttachment := OutlookMailItem.Attachments.Add(frmPrintManager.Path+'/'+frmPrintManager.InvCaption+'.XLS');
OutlookAttachment.DisplayName := '数据报表';
OutlookMailItem.Subject :=Trim(frmEmailFile.edtCaption.Text);
OutlookMailItem.Body := frmEmailFile.Title.Lines.Text;
OutlookMailItem.Importance := olImportanceHigh;
OutlookMailItem.Send;
finally
OutlookRecipient := Unassigned;
OutlookAttachment := Unassigned;
OutlookMailItem := Unassigned;
OutlookFolder := Unassigned;
OutlookNameSpace := Unassigned;
Outlook := Unassigned;
end;
end;
 
后退
顶部