NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
Set Email = CreateObject("CDO.Message")
Email.From = "hnxxcxg@sohu.com"
'Email.To ="hnxxcxg.ca71ad8@m.yinxiang.com"
Email.To = "254072148@qq.com"
Email.Subject = "say hello"
Email.Textbody = "test body "
'Email.AddAttachment ""
With Email.Configuration.Fields
.Item(NameSpace&"sendusing") = 2
.Item(NameSpace&"smtpserver") = "smtp.sohu.com"
.Item(NameSpace&"smtpserverport") = 25
.Item(NameSpace&"smtpauthenticate") = 1
.Item(NameSpace&"sendusername") = "hnxxcxg@sohu.com"
.Item(NameSpace&"sendpassword") = "XXX"
.Update
End With
Email.Send

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
schema = "http://schemas.microsoft.com/cdo/configuration/"
Flds.Item(schema & "sendusing") = 2
Flds.Item(schema & "smtpserver") = "smtp.gmail.com"
Flds.Item(schema & "smtpserverport") = 465
'Flds.Item(schema & "smtpserverport") = 587
Flds.Item(schema & "smtpauthenticate") = 1
Flds.Item(schema & "sendusername") = "gz02189@gmail.com"
Flds.Item(schema & "sendpassword") = "xxx"
Flds.Item(schema & "smtpusessl") = 1
Flds.Update
With iMsg
'.To = "hnxxcxg128.8f33072@m.yinxiang.com"
.To = "254072148@qq.com"
.From = "gz02189@gmail.com"
.Subject = wscript.arguments.item(0)
.HTMLBody = message
.Sender = " "
.Organization = " "
.ReplyTo = " "
Set .Configuration = iConf
SendEmailGmail = .Send
End With
set iMsg = nothing
set iConf = nothing
set Flds = nothing

 
 
procedure TForm1.SendMail;
begin
  with IdSMTP1 do
  begin
    Host:='smtp.163.com';
    Port:=25;
    Username:='XXOO';
    Password:='13800138000';
    AuthenticationType:=atLogin;
  end;
 
  with IdMessage1 do
  begin
    MessageParts.Clear;
    Recipients.EMailAddresses:='10086@qq.com';
    From.address:='XXOO@163.com';
    Subject:='Hello';
    Body.Add('Hello World');
  end;
 
  TIdAttachment.Create(IdMessage1.MessageParts,'D:\1.xls');
 
  try
  IdSMTP1.Connect;
  except on E: Exception do
    begin
      showmessage('连接服务嚣失败:'+E.Message);
      exit;
    end;
  end;
 
  try
  if IdSMTP1.Authenticate then
  begin
    try
    IdSMTP1.Send(IdMessage1);
    except on E: Exception do
      begin
        showmessage('在发送过程中发生错误:'+E.Message);
        exit;
      end;
    end;
 
    showmessage('发送成功!');
  end;
  finally
    IdSMTP1.Disconnect;
  end;
end;

vbs脚本发送邮件的更多相关文章

  1. 用VBS脚本发邮件

    需求是这样的:针对账号的管理,如果发现该账号的管理员给账号加了批注,(比如要过期,修改密码,完善资料等),就需要找到这样的账号及其管理的邮件,然后发邮件给他们的管理员同时抄送给账号以达到提醒的目的.那 ...

  2. VBS脚本病毒特点及如何防范3(转)

    5.Vbs病毒生产机的原理介绍 所谓病毒生产机就是指可以直接根据用户的选择产生病毒源代码的软件.在很多人看来这或许不可思议,其实对脚本病毒而言它的实现非常简单. 脚本语言是解释执行的.不需要编译,程序 ...

  3. 使用vbs脚本进行批量编码转换

    使用vbs脚本进行批量编码转换 最近需要使用SourceInsight查看分析在Linux系统下开发的项目代码,我们知道Linux系统中文本文件默认编码格式是UTF-8,而Windows中文系统中的默 ...

  4. 在本地主机上powershell中连接远程主机执行vbs脚本,得到执行结果(2008版及以上)

    在桌面版的主机上远程管理服务器版主机,在本地powershell中连接远程主机执行vbs脚本,得到执行结果. 执行步骤: 1.将本地主机上的Hyper.vbs复制到远程连接主机上.例如,本地vbs脚本 ...

  5. [VBS]脚本中的字典、动态数组、队列和堆栈

    今天用VBS脚本写了几个程序,用到了字典(Dictionary).动态数组(ArrayList).队列(Queue)和堆栈(Stack).现在写篇Blog总结一下 :-) 1.编写环境 今天突发奇想下 ...

  6. Vbs脚本经典教材(转)

    Vbs脚本经典教材(最全的资料还是MSDN) —为什么要使用Vbs? 在Windows中,学习计算机操作也许很简单,但是很多计算机工作是重复性劳动,例如你每周也许需要对一些计算机文件进行复制.粘贴.改 ...

  7. 监视系统3389的VBS脚本

    Title: 监视系统3389的VBS脚本 --2010-10-27 19:56 从网上找的,不知道是不是NP写的那个 ---------------------------------------- ...

  8. 自动删除超过30天文件的vbs脚本【转发】

    利用代码制作自动删除超过30天的文件及文件夹的vbs脚本,定期清理文件夹中长时间无用文件. 1.首先在新建一个文本文档,粘贴代码(代码可通过添加微信公众号vbs_edit(VBS脚本之家)回复018获 ...

  9. VBS脚本和HTML DOM自动操作网页

    VBS脚本和HTML DOM自动操作网页 2016-06-16 10:24 1068人阅读 评论(0) 收藏 举报  分类: Windows(42)  版权声明:本文为博主原创文章,未经博主允许不得转 ...

随机推荐

  1. hdu 1043 pku poj 1077 Eight (BFS + 康拓展开)

    http://acm.hdu.edu.cn/showproblem.php?pid=1043 http://poj.org/problem?id=1077 Eight Time Limit: 1000 ...

  2. css 多行显示省略号....

    CSS属性如下: white-space: nowrap; overflow: hidden; text-overflow: ellipsis;

  3. hdu 3717

    思路:二分答案,然后模拟消灭石头的过程: 如果单纯的暴力模拟的话,肯定会T的: 所以要用到一定的技巧来维护: 在网上看到大神们用O(n)的复杂度来优化,真心orz: 原理是这样的:用一个变量sum_2 ...

  4. 玩玩EXPRESSJS

    呵呵,反正有的是学习时间哈哈, 这个EXPRESSJS,看看实现的大约. 看的是http://www.expressjs.com.cn/ 代码A: var express = require('exp ...

  5. php数组遍历 使用foreach

    <?php $url = array ( '新浪' =>'www.sina.com' , '雅虎' =>'www.yahoo.com' , '网易' =>'www.163.co ...

  6. 【无聊放个模板系列】POJ2752 EXKMP

    #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...

  7. http://www.ruanyifeng.com/blog/2011/09/restful

    http://www.ruanyifeng.com/blog/2011/09/restful

  8. easyui源码翻译1.32--Messager(消息窗口)

    前言 使用$.messager.defaults重写默认值对象.下载该插件翻译源码 消息窗口提供了不同的消息框风格,包含alert(警告框), confirm(确认框), prompt(提示框), p ...

  9. 图像色彩空间YUV和RGB的差别

    http://blog.csdn.net/scg881008/article/details/7168637 假如是200万像素的sensor,是不是RGB一个pixel是2M,YUV是1M? 首先, ...

  10. 【HDOJ】1508 Alphacode

    简单DP.考虑10.20(出现0只能唯一组合).01(不成立). /* 1508 */ #include <iostream> #include <string> #inclu ...