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

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:

[Button controlwinskin

Description: Delphi VclSkin 2.60 VCLSkin is an VCL library that extend Delphi application with skinnable user interface . Unlike other skin component that you must modify source code to build skinnable application, VCLskin can skin existing application using VCL components without source code modification. VclSkin automatically skin kinds of windows in application, include Delphi forms,MDIform and common Windows dialogs (MsgBox,Open/Save,Font,Print), even the Exception MsgBox. Vclskin not only support Delphi standard controls, but also support many third-party component, such as TMS Grid pack, EnLib Grid, Developer Express QuantumGrid. It is an excellent choice for those wanting to skin existing applications. The cool thing is that it uses existing VCL components. Demo version adds a string VclSkin demo on form caption, but allows to test all available functions.-Delphi VclSkin 2.60 VCLSkin is an VCL libra ry that extend Delphi application with skinnab le user interface. Unlike other skin component that you must modify source code to build skinna ble application, VCLskin can skin existing application using VC L components without source code modification . VclSkin automatically skin kinds of windows i n application, include Delphi forms, MDIform and common Windows dialogs (MsgBox. Open/Save, Font, Print) even the Exception MsgBox. Vclskin not only sup port Delphi standard controls, but also support many third-party component, TMS such as Grid pack, EnLib Grid, Developer Express QuantumGrid. It is an excel ent choice for those wanting to skin existing ap plications. The cool thing is that it uses exist ing VCL components. Demo version adds a strin
Platform: | Size: 5241856 | Author: 史旭龙 | Hits:

[Delphi VCLpngimage1.56

Description: This PNG Delphi version 1.56 documentation (this version is a major rewrite intended to replace the previous version, 1.2). Improvements in this new version includes: This new version allows the programmer to not use Delphi heavy units which will greatly reduce the size of the final executable. Read more about this feature here. Most, if not all, Portable Network Graphics features as CRC checking are now fully performed. Error on broken images are now better handled using new exception classes. The images may be saved using interlaced mode also. Transparency information won t be discarted after the image is loaded any more. Most of the images are decoded much faster now. The images will be better encoded using fresh new algorithms. IMPORTANT! Now transparency information is used to display images. -Delphi version 1.56 documentat ion (this version is a major rewrite intended to replace the previous version. 1.2). Improvements in this version include new s : This new version allows the programmer to not us e Delphi heavy units which will greatly reduce t he size of the final executable. Read more about this feature here. Most, if not all, Portable Network Graphics features as CRC Checkout king are now fully performed. Error on broken im ages are now better handled using new exception classes. The images may be saved using interlac ed mode also. Transparency information won t be discarted after the image is loaded any more. Mo st of the images are decoded much faster now. The better images will be encoded using fresh new al gorithms. IMPORTANT! Now transparency inform ation is used to d
Platform: | Size: 291840 | Author: Han Xun | Hits:

[OtherCalculator

Description: 自制计算器,可以连加,连减,连剩,连除.-Self-made calculators, you can even increase, even by, even the left, even the exception.
Platform: | Size: 8192 | Author: 黑色游戏 | Hits:

[Delphi VCLEurekaLog.v6.0.1.4

Description: EurekaLog 是集成在 Delphi, C++Builder, Visual Studio 等 IDE 下的辅助工具,能快速生成带 Error Report 功能的应用程序。能将错误报告发送到指定邮箱、服务器、记录在本地文件中等。其报告可具体指出出错的代码行,以及机器当前信息、寄存器信息等诸多重要诊断信息。新版还支持内存泄露检测。 -EurekaLog is a complete bug resolution tool for Delphi, C++Builder, C# and VB.NET developers that gives your application the power to catch every exception and memory leak, directly on the end user PC, generating a detailed log of the call stack (with file, class, method and line number), optionally sending you a copy of each log entry via email or the Web
Platform: | Size: 13784064 | Author: aldz | Hits:

[Windows Developpanclock

Description: TPanelClock -一个VCL组件是提供时间日期,数量,和滚动关键状态。当您按下此组件(在运行时) ,它将切换到免费的GDI显示,系统和用户资源。-{ TPanelClock- a VCL component that is provides time-of-date, NUM, CAPS, and } { Scroll Key Statuses. When you click on this component (at run-time), it } { will switch to showing free GDI, System, and User Resources. Source code } { documentation is rather limited, with the exception of the rather arcane } { properties which as described below. This component (such as it is) is } { hereby given to the public domain. Should you find it useful at some } { point in your programming career, please feel obligated to donate one of } { your own equally useful components to the public domain. If you have any } { suggestions for improvements, or if you find any bugs, please notify the } { author (but please be gentle- this is my first component). Thank-you. }
Platform: | Size: 12288 | Author: Sam | Hits:

[Delphi VCLException

Description: Delphi 异常处理是软件处理中很重要的一个技术,可以防止软件的不正常运行。-Delphi is a software exception handling to deal with a very important technology, could not prevent the normal operation of software.
Platform: | Size: 4096 | Author: 陈树 | Hits:

[Delphi VCLDelphi-Kylix

Description: This book is about database programming in Delphi 6 and Kylix. Most of the code in the book (with the exception of the dbExpress chapters) should also work with Delphi 5, but I have made no effort to test it.
Platform: | Size: 1874944 | Author: leventsa | Hits:

[Delphi/CppBuilderdelphi-in-a-nutshell.9781565926592.25234

Description: Overview of Delphi Object Pascal, units and libraries, data and string types, exception handling, file I/O, classes and objects, inheritance, constructors and destructors, interfaces, reference counting, Windows messages, memory management strategies, virtual method tables (VMTs), properties, using TypInfo, virtual and dynamic methods, automated methods and COM, Delphi type information and RTTI, concurrent programming with threads, synchronization, thread local storage techniques, Delphi language reference, system constants, operator reference, compiler directives, code samples, and programming tips.
Platform: | Size: 19062784 | Author: chane | Hits:

[xml-soap-webservice80921_XmlToolEditor

Description: TXmlTool 支援以下功能(特徵): 1. 可解析 XPath 2. 自動建造 XPath 的相關 Nodes 3. 具有 Exception 忽略能力 4. 以 XmlDom 為存取基礎, 不會影響原有的 XML 運作.-TXmlTool supports the following functions (features): 1. Can be resolved XPath 2. Automatic Construction of XPath related to Nodes 3. With the Exception ignore the capacity of 4. XmlDom of access, and will not affect the operation of the original XML.
Platform: | Size: 993280 | Author: river | Hits:

[Delphi VCLDelphNetTraffic

Description: delphi编写的网络流量监视软件,用于监视网络流量是否出现异常-delphi write network traffic monitoring software for monitoring network traffic, whether there is an exception
Platform: | Size: 243712 | Author: 潘凌昀 | Hits:

[ADO-ODBCExam96

Description: 该源码主要是通过为ApplicationEvents的OnException事件安装了一个处理程序,实现了数据库各种异常错误的处理。-The source is mainly through the OnException events ApplicationEvents install a handler to achieve a variety of database exception error handling.
Platform: | Size: 337920 | Author: hanlisxy | Hits:

[Process-ThreadThreadSyncExample

Description: 在多线程中操作VCL对象时,需Synchronize到主线程,否则可能引起“Canvas does not allow drawing”异常。这是一个的线程同步例子,同时放了2种代码,可对照理解Synchronize的作用。-It s an example about how to operate VCL object in multithread. Use "Synchronize" To avoid "Canvas does not allow drawing" exception.
Platform: | Size: 201728 | Author: waters | Hits:

[Otherdelphi_jdbcrm

Description: Delphi 编程入门经典教程,讲解Delphi快速入门的基础知识、面向对象编程的方法、字符串列表及应用、文本编辑器的设计、Delphi图形编程、文件管理、拖放编程、异常处理与程序调试、数据浏览部件的应用及编程、简单的数据库编程应用,动态链接库编程指南等。-Introduction to the classic Delphi Programming Tutorial, Getting Started Delphi explaining the basics of object-oriented programming method, the string list and the application of the design of a text editor, Delphi graphics programming, file management, drag and drop programming, exception handling and debugging, data browsing application components and programming, a simple database application programming, dynamic link library programming guides.
Platform: | Size: 439296 | Author: 松公子 | Hits:

[Delphi VCLvclskin503

Description: VCLSkin 是Delphi应用程序的扩展VCL类库用来制作用户界面的皮肤。不像其他的部件,要变换应用程序的皮肤,必须修改源代码重新编译,VCLSkin可以变换现有应用程序的皮肤不用修改源代码。 VCLSkin自动变换应用程序中的各种窗口的皮肤。包括Delphi Forms, MDIForm和通常的Windows对话框(MsgBox,Open/Save,Font,Print),甚至Exception对话框。 VCLScrin不仅支持Delphi标准控件,也支持许多第三方控件,例如TMS Grid pack, EnLib Grid, Developer Express QuantumGrid。对于那些想让现有软件换肤的人来说,VCLSkin是最理想的选择。最酷的是,它使用现有的VCL部件。 本软件包含了全部源程序,支持Delphi5,6,7等各种版本,根据自己的环境并入到自己的软件中,还提供了演示程序,获得直观效果。-VCLSkin is an VCL library that extend Delphi application with skinnable user interface . Unlike other skin component that you must modify source code to build skinnable application, VCLskin can skin existing application using VCL components without source code modification. VclSkin automatically skin kinds of windows in application, include Delphi forms,MDIform and common Windows dialogs (MsgBox,Open/Save,Font,Print), even the Exception MsgBox. Vclskin not only support Delphi standard controls, but also support many third-party component, such as TMS Grid pack, EnLib Grid, Developer Express QuantumGrid. It is an excellent choice for those wanting to skin existing applications. The cool thing is that it uses existing VCL components.
Platform: | Size: 12049408 | Author: liaowenjia | Hits:

[Delphi VCLDelphi_debug_exception_handler

Description: Delphi异常处理程序调试Delphi debug exception handler-Delphi exception handler to debug Delphi debug exception handler
Platform: | Size: 273408 | Author: oz | Hits:

[Process-Threadasynccalls-thread-pool-example

Description: 利用多线程异步函数调用。 {版本:2.98(2011年10月22日)} {添加:德尔福XE264位的支持} {} {版本:2.97(2011-05-21)} {修正:线程的优先级恢复正常新AsyncCall任务。 } {修正:代替暂停/恢复代码,以防止竞争条件,在所有线程} {暂停但他们FSuspended标志是假的。 } {修正:异常处理TAsyncCall.InternExecuteSyncCall。退出()后不叫AN} {引发异常。 } -Asynchronous function calls utilizing multiple threads. { Version: 2.98 (2011-10-22) } { Added: Support for Delphi XE2 64bit } { } { Version: 2.97 (2011-05-21) } { Fixed: The thread priority wasn t reset to Normal for new AsyncCall tasks. } { Fixed: Replaced Suspend/Resume code to prevent a race condition where all threads are } { suspended but their FSuspended flag is false. } { Fixed: Exception handling in TAsyncCall.InternExecuteSyncCall. Quit() wasn t called after an } { exception was raised. }
Platform: | Size: 106496 | Author: xkyzmr | Hits:

[Delphi/CppBuilderException-Handling

Description: DELPHI中异常处理与程序调试,介绍DELPHI 7异常处理原理-Exception Handling and Debugging
Platform: | Size: 15360 | Author: 阿攀 | Hits:

[Delphi/CppBuilderDelphi

Description: delphi高手突破...VCL OOP 异常处理-The delphi masters breakthrough ... VCL OOP exception handling ..
Platform: | Size: 5537792 | Author: fklja | Hits:

[Delphi VCLexception

Description: Delphi“异常”处理演示程序,编程学习源码,很好的参考资料。-Delphi "abnormal" processing demo program, learning programming source code, a good reference.
Platform: | Size: 4096 | Author: 什锦豆腐 | Hits:
« 12 »

CodeBus www.codebus.net