在“打印屏幕”之后,我将图像粘贴到cxImage组件中。
我如何告诉LMDMapiSendMail1 (从the创新组件)将cxImage的内容作为附件发送?
发布于 2014-09-23 15:44:32
正如雷米所说,因为LMDMapiSendMail1将附件作为文件处理,所以必须首先保存该文件。我找到了一个将printscreen保存到文件的好例子(Mike )。将其应用于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');
不太优雅,但很实用。
但是,我通过单击按钮简化了所有操作(在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;简单多了。
https://stackoverflow.com/questions/25983443
复制相似问题