LMD MapiSendMail 1 - 将打印屏幕作为附件发送

时间:2014-09-22 21:32:09

标签: delphi devexpress delphi-xe6

打印屏幕'我将图像粘贴到cxImage组件中。

如何告诉LMDMapiSendMail1(来自lmdinnovative)组件将cxImage的内容作为附件发送?

1 个答案:

答案 0 :(得分:0)

由于LMDMapiSendMail1将附件作为文件处理,如Remy所说,必须首先保存文件。我找到了一个将打印屏幕保存到文件的好例子(Mike Shkolnik)。将其应用于cxImage1属性更改:

procedure TForm11.cxImage1PropertiesChange(Sender: TObject);
var DCDesk: HDC;
bmp: TBitmap;
begin
bmp := TBitmap.Create;
  bmp.Height := Screen.Height;
  bmp.Width := Screen.Width;
  DCDesk := GetWindowDC(GetDesktopWindow);
  BitBlt(bmp.Canvas.Handle, 0, 0, Screen.Width, Screen.Height,
         DCDesk, 0, 0, SRCCOPY);
  bmp.SaveToFile('ScreenShot.bmp');
  ReleaseDC(GetDesktopWindow, DCDesk);
  bmp.Free;
end;

将文件保存在application.exe文件夹中。现在剩下要做的就是告诉 文件所在的LMDMapiSendMail1并将其添加为附件,如:

  

LMDMapiSendMail1.Attachment.Append(' ScreenShot.bmp&#39);

不是很优雅,但它有效。

编辑: 但是,我通过点击按钮简化了所有内容(在我将照片粘贴到cxImage1之后):

procedure TForm11.AdvGlowButton2Click(Sender: TObject);
begin
cxImage1.Properties.GraphicClassName:='TJPEGImage';
cxImage1.picture.SaveToFile(extractfilepath(application.ExeName)+'picture.jpg');
end;

然后就做了:

procedure TForm11.AdvGlowButton1Click(Sender: TObject);
Var Path: String;
begin
Path:= ExtractFilePath(Application.ExeName);
LMDMapiSendMail1.Attachment.Append(Path + 'picture.jpg');
end;

更简单......