×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

I am struggling on sending email function by using a free .dll mailer, please VB expert help. Thanks a lot.

I downloaded the mailer from 'http://www.freevbcode.com/ShowCode.ASP?SearchString=vbSendMail.dll&ID=109'.

As mailer document said,
'Module Level Declaration (WithEvents optional but recommended)
Private WithEvents poSendMail as vbSendMail.clsSendMail

I got a error message 'Compile error:Only valid in object module', red highlight on 'WithEvents'

After I removed 'WithEvents' and tried to run the program, got a error message 'Compile error:User-defined type not defined',red highlight on 'poSendMail As vbSendMail.clsSendMail'.

Actually I already copied .dll to C:/WINDOWS, seems like I have trouble to introduce dll into my VB code.
Report

Replies, comments and Discussions:

  • 工作学习 / 学科技术讨论 / Batch file expert, Please come in
    I am going to write a batch file or script (.bat) on Windows XP for below functions:

    1. Check two input files available
    2. Run a macro in the MS EXCEL
    3. Send out an email with the attachment

    Please the expert of batch file advise if the batch file can work for my functions.
    • Any reason for you still to prefer to DOS commands?
      • No special reason. I am not windows programmer, so I am not quite sure what is the best way.
        • AFAIK, it’s hard to achieve all your goals by DOS commands.
    • i am not sure about the 2nd task. 1 and 3 are doable. But you might need a 3rd party tool to compose email and access your mail server.
      • Can you help to give me more information? I am not windows programmer.
    • U need smtp service to sent out mail,in widows system,CDO will beth easiest way.Check MSDN for CDO.
    • first, you need a script language installed on your pc. I don't think dos command can do this job.
    • DOS没戏,纯DOS只有1) 能做。
    • A PHP or Perl Script will definitely do the job. A simple VB program is also a good choice.
    • 不知道最好的解决方案是什么,但是Perl100%可以实现你的要求
    • 写个这样的程序也很简单,没有多少语句,我记得有自动运行的程序,就象自动测试一样。
    • Thanks very much ALL. I have never used PHP or Perl before, VB is fine to me(10 year ago,haha).
      • 用vb可以做的
        • I am struggling on sending email function by using a free .dll mailer, please VB expert help. Thanks a lot.
          I downloaded the mailer from 'http://www.freevbcode.com/ShowCode.ASP?SearchString=vbSendMail.dll&ID=109'.

          As mailer document said,
          'Module Level Declaration (WithEvents optional but recommended)
          Private WithEvents poSendMail as vbSendMail.clsSendMail

          I got a error message 'Compile error:Only valid in object module', red highlight on 'WithEvents'

          After I removed 'WithEvents' and tried to run the program, got a error message 'Compile error:User-defined type not defined',red highlight on 'poSendMail As vbSendMail.clsSendMail'.

          Actually I already copied .dll to C:/WINDOWS, seems like I have trouble to introduce dll into my VB code.
          • Loot at MS component CDONTS.dll.
    • we use this vbscript to send mail. in dos batch add line ---------------- cscript.exe //nologo f:\backup\send-report.vbs ------------ hope it helps
      Set objEmail = CreateObject("CDO.Message")
      set oFSO = CreateObject("Scripting.FileSystemObject")
      set oFile = oFSO.OpenTextFile("report.txt")

      objEmail.From = "backups@abc.ca"
      objEmail.To = "it@abc.ca"
      objEmail.Subject = "Backup Report"
      objEmail.Textbody = oFile.ReadAll
      objEmail.Configuration.Fields.Item _
      ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      objEmail.Configuration.Fields.Item _
      ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
      "mail.abc.ca"
      objEmail.Configuration.Fields.Item _
      ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
      objEmail.Configuration.Fields.Update
      objEmail.Send

      oFile.Close
      • it might work only for MS Exchange Server. correct me if I'm wrong.
        • CDO for Windows 2000 can send messages using the SMTP or Via Exchange server. Either way, SMTP server should be installed in working machine. It looks like that when using Exchange server, SMTP server works as relay.
        • Yes, you are wrong. you can use CDO.Message as long as you have CDOSYS component ( preinstalled on 2003.) you just need a smtp server ( can be local or remote).