|
|
|
| | |
|
(4 ) +
1.
DoCmd.SendObject ...
.
2.
Application.FollowHyperlink"mailto:kozin@mail.ru?subject= &body= ", , True
3.MAPI
,:
(MSOutlookExpressMSOutlook)
PublicSubtestSengMultyattach()
ConstSESSION_SIGNON=1
ConstMESSAGE_COMPOSE=6
ConstATTACHTYPE_DATA=0
ConstRECIPTYPE_TO=1
ConstRECIPTYPE_CC=2
ConstMESSAGE_RESOLVENAME=13
ConstMESSAGE_SEND=3
ConstSESSION_SIGNOFF=2
DimMS'MAPISession
DimMsgs
SetMS=CreateObject("MSMAPI.mapiSession.1")
SetMsgs=CreateObject("MSMAPI.mapiMessages.1")
MS.signon
Msgs.sessionid=MS.sessionid
Msgs.compose
Msgs.msgsubject="Itestyousample"
Msgs.msgnotetext="Thisworks"
Msgs.RecipIndex=0'Firstrecipient
Msgs.RecipType=RECIPTYPE_TO
Msgs.RecipDisplayName="kozin@mail.ru"'RecipientinTOline.thismymail:))
Msgs.AttachmentType=0
Msgs.AttachmentIndex=0
Msgs.AttachmentPathName="c:\CONFIG.SYS"
Msgs.AttachmentPosition=0
Msgs.AttachmentIndex=1'nextnumber!!!
Msgs.AttachmentPathName="c:\autoexec.bat"
Msgs.AttachmentPosition=1
'asktocommit
Msgs.send("1")
'orsendauto
'Msgs.Action=MESSAGE_SEND
'CloseMAPImailsession:
MS.Action=SESSION_SIGNOFF
EndSub
4.CDO
PrivateSubSendCDOmail()
DimMsg'AsCDO.Message
SetMsg=CreateObject("CDO.Message")
DimmailaddressAsString
DimMsghtmlAsString
mailaddress="kozin@mail.ru"
Msghtml="<HTML><h2>.</h2></HTML>"
WithMsg
.HTMLBody=Msghtml
.AddAttachment("c:\autoexec.bat")
.To="""Administratior""<"&mailaddress&">"
.FROM="""""<mailservice@mailserver.ru>"
.Send
EndWith
SetMsg=Nothing
EndSub
CDO
"MicrosoftCDOforExchange2000"
(cWindows2000..
OS)
CDO-.
:
.
PrivateFunctionSendCDOmail(mailaddressAsString,filename)AsString
'
OnErrorGoToerrh:
DimMsg'AsCDO.Message
SetMsg=CreateObject("CDO.Message")
DimMsghtmlAsString
Msghtml="<HTML><h2>.</h2></HTML>"
Msg.HTMLBody=Msghtml
Msg.AddAttachment(filename)
'SMTP,
'
'!!!!
WithMsg.Configuration.Fields
ConstcdoSendUsingMethod="http://schemas.microsoft.com/cdo/configuration/sendusing"
ConstcdoSendUsingPort=2
.Item(cdoSendUsingMethod)=cdoSendUsingPort
ConstcdoSMTPServer="http://schemas.microsoft.com/cdo/configuration/smtpserver"
.Item(cdoSMTPServer)="192.168.2.3"'IPSMTP
ConstcdoSMTPConnectionTimeout="http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
.Item(cdoSMTPConnectionTimeout)=360'
ConstcdoSMTPAuthenticate="http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
'ConstcdoBasic=1
ConstcdoAnonymous=0
.Item(cdoSMTPAuthenticate)=cdoAnonymous
EndWith
Msg.Configuration.Fields.Update
WithMsg
.To="""""<"&mailaddress&">"
.FROM="""""<@.ru>"
.Send
EndWith
ExitFunction
errh:
SendCDOmail=Err.Description
EndFunction
PrivateFunctionMoveFileToARC(filenameAsString)
'rar
'WinRaR
'-
DimrarfileAsString
rarfile=Environ("tmp")&"\"&Fix(Timer)&Replace(filename,".xls",".rar",,,vbTextCompare)
OnErrorResumeNext
Killrarfile
OnErrorGoTo0
IfTrim(filename)=""ThenMsgBox"":ExitFunction
'RAR<>-<1>-<N><><...>
DimOShell
SetOShell=CreateObject("WScript.Shell")
DimDosCommand
DosCommand=Chr(34)&Environ("programfiles")&"\winrar\rar.exe""a-ep"&rarfile&""&Environ("tmp")&"\"&filename
'Debug.PrintDosCommand
DoEvents
CallOShell.Run(DosCommand,2,True)
DoEvents
OnErrorResumeNext
KillEnviron("tmp")&"\"&filename
OnErrorGoTo0
IfDir(rarfile)<>""ThenMoveFileToARC=rarfile
EndFunction
:
PrivateSubsendmail_Click()
IfNz(Me.mailaddress,"")=""ThenMsgBox"":ExitSub
DimARCfile,srcfileAsString
DoCmd.HourglassTrue
srcfile="c:\autoexec.bat"
ARCfile=MoveFileToARC(srcfile)
IfARCfile=""ThenMsgBox"":ExitSub
Dimsendresult
sendresult=SendCDOmail(Me.mailaddress,ARCfile)
KillARCfile
DoCmd.HourglassFalse
Ifsendresult<>""Then
MsgBox"email:"&sendresult
Else
DoCmd.CloseacForm,Me.name
MsgBox""&srcfile&"."
EndIf
EndSub
| |
| | |