PDA

Click to See Complete Forum and Search --> : Opening the default mail client


Apr 26th, 2000, 10:21 AM
This is done on http://memberservices.msn.com/

I need a script that when you click on the link the machines default mail client launches. I have extracted the code from the microsoft page but cant seem to get it to work. Can anyon help?

Thanks
Jeremy

Here is the code I extracted in two different parts

<SCRIPT LANGUAGE="VBScript">
dim bnDebug,mailChecked
dim beginHTML,endHTML
dim bMailFrameLoaded
bMailFrameLoaded=false
bnDebug=true
mailChecked=false
sub Window_OnLoad
if bnDebug then on error resume next
WaitForControls 1
end sub
sub WaitForControls(loops)
if bnDebug then on error resume next
if(fIsMsndcLoaded()=TRUE)then
CheckMail
else
if(loops<10)then
setTimeOut "WaitForControls "&CStr(loops+1),500,"VBScript"
else
setTimeOut "setMailStatus -2, 1",5000,"VBScript"
end if
end if
end sub
function fIsMsndcLoaded()
if bnDebug then on error resume next
fIsMsndcLoaded=false
if(IsObject(msndc))then
msndc.Mail_Version
if(Err.Number<>0)then exit function
if(msndc is Nothing)then exit function
if(Err.Number<>0)then exit function
fIsMsndcLoaded=TRUE
end if
end function
sub CheckMail
if bnDebug then on error resume next
msndc.MAIL_Refresh
if(Err.Number<>0)then
setMailStatus-2,1
end if
end Sub
sub msndc_MAIL_OnRefreshComplete(hresult)
if bnDebug then on error resume next
dim msgs
msgs=msndc.MAIL_HeaderCount
if(Err.Number=0)Then
setMailStatus msgs,1
else
setMailStatus-2,1
end if
end sub
sub msndc_Error(ErrorCode,bstrPrefix,bstrError,bHandled)
if bnDebug then on error resume next
'the error is not authenticated . . .
if(ErrorCode=-2147184629)then
setMailStatus-2,1
setTimeOut "CheckMail",12000,"VBScript"
end if
end sub
sub setMailStatus(status,count)
dim nStatus
beginHTML="<A HREF='javascript:LaunchMail()'><CENTER><B CLASS=mclink>"
endHTML="</B></CENTER></A>"
if bnDebug then on error resume next
clearTimeout mailStatusTimer
nStatus=CInt(status)
if(bMailFrameLoaded=true)then
if(nStatus<0)then
main.innerHTML=beginHTML+"Click here to start e-mail"+endHTML
end if
If(nStatus=0)or(nStatus>=2)then
main.innerHTML=beginHTML+"You have "+CStr(nStatus)+" new messages."+endHTML
end if
If(nStatus=1)then
main.innerHTML=beginHTML+"You have "+CStr(nStatus)+" new message."+endHTML
end if
elseif CInt(count)<5 then
mailStatusTimer=setTimeout("setMailStatus "&CStr(status)&","&CStr(CInt(count)+1),3000,"VBScript")
exit sub
end if
end sub
sub LaunchMail
if bnDebug then on error resume next
if(IsObject(msndc))then
msndc.MAIL_LaunchMail
end if
if Err.number<>0 then
alert("Unfortunately, this feature is offered to MSN Members only.")
end if
end sub
</SCRIPT>

<div id=main>
<SCRIPT LANGUAGE="vbscript">
bMailFrameLoaded=true
beginHTML="<A HREF='javascript:LaunchMail()'><CENTER><B CLASS=mclink>"
endHTML="</B></CENTER></A>"
If Instr(window.navigator.appVersion,"3")Then
document.writeln(beginHTML+"Click here to start email"+endHTML)
else
document.writeln(beginHTML+"Checking e-mail..."+endHTML)
end if
</SCRIPT></div>
<object id="msndc" width=0 height=0 classid="clsid:8B25AB10-91C7-11D0-81A1-00AA00BF9457"></object>