资源描述:
《邮件群发-不同邮件发不同人(从excel,利用notes)99208》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、邮件群发-不同邮件发不同人(从excel,利用notes)99208Sub保存到草稿箱()DimnoSessionAsObject,noDatabaseAsObject'noSession??noDatabase??DimnoDocumentAsObject,noAttachmentAsObject'noDocument??noAttachment??DimI%,FileSelf$,jAsInteger'stMsg$,'I=邮件数量stMsg=.Body邮件信体FileSelfjDimvaRecipient()AsString'vaRecipie
2、nt=.sendto邮件地址DimvaFiles()AsString'vaFiles附件地址和路径DimstMsg()AsString'修改原程序,将邮件信体设置为字符串数组DimstSubject()AsString'修改原程序,将邮件标题设置为字符串数组DimshAsShape'sh'stMsg="Best&Regards"&vbCrLf&_'Application.UserName&vbCrLf&_'vbCrLf&_'"-------------------------------------------------------------
3、-------------"&vbCrLf&_'"(重要文件,因涉及个人奖金评价,请重视。)"&vbCrLf&_'"(填写完毕后,请及时上交给我,谢谢。)"'****取消原程序用窗体控件的部分,改为用特征字列'I=0'ReDimvaRecipient(ActiveSheet.Shapes.Count-1)AsString'邮件地址数组的大小=活动勾选框-1'ReDimvaFiles(ActiveSheet.Shapes.Count-1)AsString'附件地址和路径数据数组的大小=活动勾选框-1'ReDimstMsg(ActiveSheet.S
4、hapes.Count-1)AsString'邮件信体数组的大小=活动勾选框-1'ReDimstSubject(ActiveSheet.Shapes.Count-1)AsString'邮件主题数据的大小=活动勾选框-1''ForEachshInActiveSheet.Shapes'Ifsh.Type=msoFormControlThen'msofromcontrol=窗体控件'Ifsh.FormControlType=xlCheckBoxThen'xlcheckbox=复选框'Ifsh.ControlFormat.Value=1Then'找出勾选
5、的邮件地址'vaRecipient(I)=sh.BottomRightCell.Offset(0,1)'勾选框右边第一列为邮件地址'vaFiles(I)=sh.BottomRightCell.Offset(0,2)'勾选框右边第二列为附件地址和路径'stSubject(I)=sh.BottomRightCell.Offset(0,3)'勾选框右边第三列为邮件标题'stMsg(I)=vbCrLf&sh.BottomRightCell.Offset(0,4)&vbCrLf'勾选框右边第四列为邮件信体'I=I+1'EndIf'EndIf'EndIf'N
6、extlastrow=Range("A65536").End(xlUp).Row'查找范围erow=0ForI=1Tolastrow'计算发送邮件的有效数量IfCells(I,"A")="发送"Thenerow=erow+1NextReDimvaRecipient(erow-1)AsString'邮件地址数组的大小=有效数量-1ReDimvaFiles(erow-1)AsString'附件地址和路径数据数组的大小=有效数量-1ReDimstMsg(erow-1)AsString'邮件信体数组的大小=有效数量-1ReDimstSubject(ero
7、w-1)AsString'邮件主题数据的大小=有效数量-1I=0Forj=1TolastrowIfCells(j,"A")="发送"ThenvaRecipient(I)=Cells(j,"B")'邮件地址vaFiles(I)=Cells(j,"C")'附件地址和路径stSubject(I)=""&Cells(j,"D")'邮件标题stMsg(I)=vbCrLf&Cells(j,"E")'邮件内容I=I+1EndIfNextIfI=0ThenMsgBox"没有邮件需要发送":ExitSub'没有勾选,结束程序'ReDimPreservevaReci
8、pient(I-1)AsString'原程序就已注释掉'vaFiles=Application.GetOpenFilename(File