Welcome![Sign In][Sign Up]
Location:
Search - delphi html

Search list

[Delphi VCL带附件及Html显示的邮件发送类

Description:

unit UnitSendMail;

interface

uses
  Windows, SysUtils, Classes,StdCtrls, ExtCtrls, ComCtrls, Dialogs,
  IdMessage, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdExplicitTLSClientServerBase,IdMessageClient, IdSMTPBase, IdSMTP, IdText,
  IDAttachmentFile;

function SendEMail(SenderName, SenderAddress: PChar;
    Receivename, ReceiveAddress: PChar; MailSubject, MailContent: PChar;
    JpgFileName: PChar; SendType: Integer; PicID: PChar; IsCustom: Boolean;Attachment:PChar): Boolean; stdcall;
function ConnectMailServer(Host, UserName, Password: PChar;
    Port: Integer): Boolean; stdcall;
procedure DisconnectMail; stdcall;

type
  TSendMailObj = class
  private
    FHost: String;
    FPort: Integer;
    FUserName: String;
    FPassword: String;
    ASmtp: TIdSMTP;
  public
    property Host: string read FHost write FHost;
    property Port: Integer read FPort write FPort;
    property UserName: String read FUserName write FUserName;
    property Password: String read FPassword write FPassword;
    constructor Create;
    function ConnectServer: Boolean;
    function SendEMail(SenderName, SenderAddress: PChar;
      Receivename, ReceiveAddress: PChar; MailSubject, MailContent: PChar;
      JpgFileName: PChar; SendType: Integer; PicID: PChar;
      IsCustom: Boolean;Attachment:PChar): Boolean;
  end;

var
  SendObj: TSendMailObj;

implementation

function SendEMail(SenderName, SenderAddress: PChar;
    Receivename, ReceiveAddress: PChar; MailSubject, MailContent: PChar;
    JpgFileName: PChar; SendType: Integer; PicID: PChar; IsCustom: Boolean;Attachment:PChar): Boolean; stdcall;
begin
  Result :=  SendObj.SendEMail(SenderName, SenderAddress, Receivename,
          ReceiveAddress, MailSubject, MailContent,
            JpgFileName, SendType, PicID, IsCustom,Attachment);
end;

function ConnectMailServer(Host, UserName, Password: PChar;
    Port: Integer): Boolean; stdcall;
begin
  try
    //if SendObj = nil then
    SendObj := TSendMailObj.Create;
{    if SendObj.ASmtp.Connected then
      SendObj.ASmtp.Disconnect;  }
    SendObj.Host := StrPas(Host);
    SendObj.Port := Port;
    SendObj.Username := StrPas(UserName);
    SendObj.Password := StrPas(Password);
    Result := SendObj.ConnectServer;
  except
    Result := False;
  end;
end;

procedure DisconnectMail; stdcall;
begin
  if SendObj <> nil then
  begin
    if SendObj.ASmtp <> nil then
      SendObj.ASmtp.Disconnect;
    SendObj := nil;
    SendObj.Free;
  end;
end;
{ TSendMailObj }

function TSendMailObj.ConnectServer: Boolean;
begin
  ASmtp.Host := FHost;
  ASmtp.Port := FPort;
  ASmtp.Username := FUserName;
  ASmtp.Password := FPassword;
  try
    ASmtp.Connect;
    Result := ASmtp.Connected;
  except
    Result := False;
  end;
end;

constructor TSendMailObj.Create;
begin
  ASmtp := TIdSMTP.Create(nil);

end;

function TSendMailObj.SendEMail(SenderName, SenderAddress, Receivename,
  ReceiveAddress, MailSubject, MailContent, JpgFileName: PChar;
  SendType: Integer; PicID: PChar; IsCustom: Boolean;Attachment:PChar): Boolean;
var
  IdBody, IdHtml: TIdText;
  Att: TIdAttachmentFile;
  AMessage: TIdMessage;
  ASmtp_1: TIdSMTP;
begin
  ASmtp_1 := TIdSMTP.Create(nil);
  ASmtp_1.Host := FHost;
  ASmtp_1.Port := FPort;
  ASmtp_1.Username := FUserName;
  ASmtp_1.Password := FPassword;
  //ASmtp_1.AuthType := atDefault;
  ASmtp_1.Connect; // }
  if not ASmtp.Connected then
    ASmtp.Connect;
  AMessage := TIdMessage.Create(nil);
  with AMessage do
  begin
    NoDecode := False;
    NoEncode := False;
    ContentType := 'multipart/mixed';
    Encoding := meMIME;
    MsgId := 'PrettyPic';
    if FileExists(StrPas(JpgFileName)) then
      References := ChangeFileExt(ExtractFileName(StrPas(JpgFileName)), '')
    else
      References := '';
    Recipients.Clear;
    with Recipients.Add do
    begin
      Name := StrPas(Receivename);
      Address := StrPas(ReceiveAddress);
    end;
    Subject := StrPas(MailSubject);
    Sender.Name := StrPas(SenderName);
    Sender.Address := StrPas(SenderAddress);
    From.Name := Sender.Name;
    From.Address := Sender.Address;
    if SendType = 0 then
    begin
      IdBody := TIdText.Create(MessageParts);
      IdBody.ContentType := 'text/plain';
      IdBody.Body.Add(StrPas(MailContent));
      IdBody.Body.Add('');
    end
    else
    begin
      IdHtml := TIdText.Create(MessageParts);
      IdHtml.ContentType := 'text/html;charset=gb2312';
      IdHtml.ContentTransfer := '7bit';
      IdHtml.Body.Add(' <html>');
      IdHtml.Body.Add('  <head>');
      IdHtml.Body.Add('      <title>' + StrPas(MailSubject) + ' </title>');
      IdHtml.Body.Add('  </head>');
      IdHtml.Body.Add('  <body title="' + References + '">');
      IdHtml.Body.Add('    ' + StrPas(MailContent) + ' <br>');
      if (not IsCustom) and FileExists(StrPas(JpgFileName)) then
        IdHtml.Body.Add('      <img src="cid:' + StrPas(PicID) + '" alt="' + ExtractFileName(StrPas(JpgFileName)) +
                            '" name="' + ExtractFileName(StrPas(JpgFileName)) + '" title="">');
      IdHtml.Body.Add('  </body>');
      IdHtml.Body.Add(' </html>');
    end;
    if FileExists(StrPas(JpgFileName)) then
    begin
      Att := TIdAttachmentFile.Create(MessageParts, StrPas(JpgFileName));
      Att.ExtraHeaders.Values['Content-ID'] := StrPas(PicID);
      Att.ContentType := 'image/jpg';
    end;  
    if FileExists(StrPas(Attachment)) then
    begin
      Att := TIdAttachmentFile.Create(MessageParts, StrPas(Attachment));
    end;
  end;
  try
    ASmtp_1.Send(AMessage);
    if Att <> nil then
      Att.Free;
    if IdBody <> nil then
      IdBody.Free;
    if IdHtml <> nil then
      IdHtml.Free;
    if AMessage <> nil then
      AMessage.Free;
    ASmtp_1.Disconnect;

    ASmtp_1.Free; //}
    ASmtp.Disconnect;
    Result := True;
  except on e: Exception do
  begin
    Result := False;
  end;
  end;

end;

end.


Platform: | Size: 1685 | Author: kennyxue | Hits:

[Delphi VCL82 将ie收藏夹导出为html文件

Description: 将ie的收藏夹导出成html格式-will ie favorites derived into html format
Platform: | Size: 180224 | Author: | Hits:

[WEB Maildelphi代码

Description: 一个web页面下的发信组件,只能发送文本和html格式的邮件,支持二次开发。-a web page letter under the components, can only send text and html format of the mail, the development of secondary support.
Platform: | Size: 88064 | Author: leeh | Hits:

[RichEditTRichView.v1.9.10.2 src

Description: RichView is a suite of native Delphi/C++Builder components for displaying, editing and printing hypertext documents. Components support various character attributes (fonts, subscripts/superscripts, colored text background, custom drawn). Documents can contain tables, pictures, images from imagelists, any Delphi controls. Left, right, center or justify alignments of paragraphs, multilevel bullets and numbering, custom margins and indents, Unicode, background images, print preview, RTF import and export, HTML export, data-aware versions and more
Platform: | Size: 2454528 | Author: akay | Hits:

[GUI DevelopEduStringGrid_v2.0

Description: 功能简单说明 1)任意单元格融合,真融合与假融合; 2)列对齐(左、中、右),行对齐(上、中、下) 3)自动换行,多行表头 3)Flat,Grid3d,Lower 显示效果 4)标题排序(左键升序,右键降序),图标提示排序方向,支持大数据排序,速度非常非常快! 5)自动列宽,单列列宽 6)报表输出:打印机设置、表头、次表头、页脚、次页脚,字体、颜色、融合、对齐、列显示、打印预览、直接打印 7)导出:xls csv rtf txt html db dbf,大数据量支持,速度非常快; - 1 2 3 Flat,Grid3d,Lower 4 the title sort (ascending Left, Right descending), the ranking icon suggested direction, and support the sequencing data, the speed is very, very fast! 5) automatically out wide, six separate column width) Statement output : Printer configuration, the first table, the table the first time, footnotes, sub-footers, fonts, colors, integration, alignment, out shows, print preview, print 7) Export : Excel csv rtf txt html db dbf, data support, very fast;
Platform: | Size: 390144 | Author: 袁丽艳 | Hits:

[TreeViewTRichView1.9.15.1

Description: 用于显示、编辑和打印超文本文档,支持各种文字属性:字体、上下标、文字背景色、托拉等等。文档里可以包括表格、图片已经各种Delphi控件。段落可以实现左、右、中间对齐,多层次段标和编码,可定制的缩进。还支持Unicode编码、背景图片、打印预览、RTF输入输出、HTML输出。-for the show, edit and print-text documents in support of various character attributes : font, plus or standard, text background color, Bitola and so on. Li document may include forms, has various photographs Delphi controls. Paragraphs can be achieved left, right, middle alignment, multi-level and the standard of coding, custom indented. Also supports Unicode, background images, print preview, input and output RTF, HTML output.
Platform: | Size: 550912 | Author: 古风 | Hits:

[Windows DevelopSiteVision

Description: 一个强大的HTML编辑器(delphi全部源码)-a powerful HTML editor (delphi all FOSS)
Platform: | Size: 640000 | Author: jim | Hits:

[Delphi VCLDreamEditor13_D7

Description: 支持自定义语法高亮显示的编辑器控件,目前支持C/Pascal/Java/HTML/XML等语法。For Delphi 7-Support for custom syntax highlighting editor shows controls, currently supports the C/Pascal/Java/HTML/XML, such as grammar. For Delphi 7
Platform: | Size: 2961408 | Author: Wenjun Shen | Hits:

[WEB Codeie_ad

Description: ie页面上嵌入自己html代码的源码,先浏览b百度然后进行搜索,在搜索的类表上点击一个链接时出来自己的页面。-ie embedded in its own html page source code first and then proceed to visit the b Baidu search, type in the search form by clicking on a link from their page.
Platform: | Size: 230400 | Author: 古朔 | Hits:

[Delphi/CppBuilderdelphi

Description: 一本delhpi的讲义,经典简洁内容丰富适合delphi初学者和晋级学员-1 delhpi lectures, classic simplicity delphi rich content for beginners and advanced students
Platform: | Size: 17940480 | Author: hongqing | Hits:

[Delphi VCLUnitSendMail

Description: delphi 带图片 html功能的Mail-delphi with picture html function Mail
Platform: | Size: 2048 | Author: 薛永坤 | Hits:

[Windows Develophtmlappform

Description: HTML Application Demo This is very simple Demo to show how to write a HTML Form Application.
Platform: | Size: 29696 | Author: vlais | Hits:

[OtherEd-HTML-src-0.1-alpha

Description: html editor delphi sources
Platform: | Size: 4397056 | Author: adam2006 | Hits:

[Delphi VCLF2H-source

Description: Delphi Form to pure HTML Convertor
Platform: | Size: 54272 | Author: sonique | Hits:

[OtherSourceCode

Description: html+dll 编程 一个小程序, 希望可以帮助到大家-html+ dll programming
Platform: | Size: 1636352 | Author: lijian | Hits:

[SMSgprsmodem

Description: GSM GPRS MODEM彩信短信开发接口以标准的DLL(Dynamic Linkable Library)即动态链接库文件提供,支持彩信、短信、超长短信、Wap Push、闪信、书签推送、名片推送的发送与接收。支持几乎所有常用的开发语言,包括ASP,ASP.NET,Borland C++ Builder,Borland Delphi,HTML,PHP,VBA,VBScript,Visual Basic,Visual Basic.NET,Visual C++,Visual C#.net等,压缩包内包含常见开发语言例程-component (DLL) for sending and receiving SMS from PC using a GSM modem. Very simple usage in Visual Basic, ASP, C#(.NET), C++, etc.
Platform: | Size: 4433920 | Author: mj200909 | Hits:

[Browser Clientweb-rss-parse

Description: Html or RSS pasing example.
Platform: | Size: 7168 | Author: Vadim Semenov | Hits:

[Delphi VCLDevExpress.ExpressWeb.Framework.v1.39.for.Delphi.

Description: Welcome to the world of ExpressWeb Framework - bringing RAD WYSIWYG web development to Delphi with the first integrated HTML designer for the Delphi 6/7 IDE. With ExpressWeb Framework, you are able to fully leverage your Delphi skills by using the same Property, Method, and Event model you ve come to know within Delphi itself to build any website or web application.
Platform: | Size: 6425600 | Author: Linces | Hits:

[Delphi VCLQuick.Report.Pro.v4.07.Delphi.2007

Description: QuickReport 是用于BCB和Delphi的一款报表组件,可以简单快速的输出数据库报表。QuickReport 支持创建打印预览以免浪费纸张,支持导出数据为其他文件格式如ASCII文本、逗号分割值的文件和HTML。QuickReport 本身由 Delphi 编写,支持Delphi 所有操作数据库的模式。因此您可以将它用于旧式的基于BDE 的数据库如Paradox 和 dBase,用于多层应用环境的客户端数据表,新的Delphi 5 ADO 和 Interbase Express 组件及第三方可选数据库如Apollo。如果您需要,甚至可以用QuickReport 格式化部件打印非不是存储在数据库里的数据。-QuickReport for BCB and Delphi, a reporting component that can output simple and fast database reports. QuickReport support the creation of print preview to avoid wasting paper, to support export data to other file formats such as ASCII text, comma-separated value files and HTML. QuickReport itself is prepared by Delphi to support all operations Delphi database model. So you can use it for the old BDE-based databases such as Paradox and dBase, multi-application environment for the client-side data table, the new Delphi 5 ADO, and Interbase Express components and an optional third-party databases such as Apollo. If you need to, even the non-printing parts with the QuickReport format is not stored in the database data.
Platform: | Size: 1809408 | Author: 学习者 | Hits:

[Delphi VCLUniCode.Editor.VCL.Ver.1.3.Source

Description: Unicode editor VCL for delphi. Supports syntax highlighting and WideString/Unicode support. comes with syntax highlighter classes for Delphi, C/C++, HTML, SQL and DCG (the Delphi Compiler Generator ).
Platform: | Size: 493568 | Author: mailads | Hits:
« 12 3 4 5 6 7 8 9 10 »

CodeBus www.codebus.net