Foros del Web » Programando para Internet » ASPX (.net) »

¿En qué estoy mal?

Estas en el tema de ¿En qué estoy mal? en el foro de ASPX (.net) en Foros del Web. El error mostrado es: Código: Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Se trata de una pag. ASP que ...
  #1 (permalink)  
Antiguo 26/10/2006, 14:43
 
Fecha de Ingreso: octubre-2004
Mensajes: 55
Antigüedad: 19 años, 7 meses
Puntos: 0
Exclamación ¿En qué estoy mal?

El error mostrado es:

Código:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Se trata de una pag. ASP que estoy migrando a ASP.Net

El código es el siguiente:

Código:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" aspcompat=true%>
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<%
Dim oPOP3,oMsg,messageID,Sender,Subject,strSize,attachs,attachSize
Dim attachName,attachCID,strDate,BodyText,BodyHTML,tempFolder,virtualPath,HTML
Dim extName,contentid,count,i,name
oPOP3 = Server.CreateObject("FathMail.POP3")
oPOP3.ServerAddr = "RENDON"
oPOP3.Username = "[email protected]"
oPOP3.Password = "password"
oPOP3.Connect
if oPOP3.GetMessageCount Then
      oMsg=oPOP3.Retrieve(17)'17
	messageID=oPOP3.GetMessageID(17)'17
	Sender = oMsg.Sender
	Subject= trim(oMsg.Subject)
	strSize=oMsg.GetSize
	attachs=oMsg.GetAttachmentCount
	attachSize=oMsg.GetAttachmentSize(0)
	attachName=oMsg.GetAttachmentName(0)
	attachCID=Replace(oMsg.GetAttachmentContentID(0),"<","")
	attachCID=Replace(attachCID,">","")
	strDate=oMsg.Date
	BodyText = oMsg.Text
	BodyHTML = oMsg.TextHTML
	oMsg.SaveToFile("K:\www\Intranet\Temp\message.msg")
'==============================
 count = oMsg.GetAttachmentCount
 tempFolder="K:\www\Intranet\Temp"
 virtualPath="/Intranet/Temp/"
  If count > 0 Then
    html = "<font face=""Courier New,Arial"" size=2>"
    html = html & "<b>Attachments:</b> "
    For i = 0 to count
	'oMsg.SaveAttachment i,tempFolder
    If oMsg.SaveAttachment( i,tempFolder & "\" & oMsg.GetAttachmentName(i).toString  ) <> 0 Then
       Response.Write( "Save attachment to " & tempFolder & " failed" )
       Response.End() 
    End If
    name = oMsg.GetAttachmentName(i)
    extName = Right(name,3)
    If LCase(extName) = ".gif" Or LCase(extName) = ".jpg" Then
       contentid = oMsg.GetAttachmentContentID(i)
       If contentid <> "" Then
         bodyText = Replace( bodyText, "cid:" & contentid, virtualPath & name )
       Else
         bodyText = bodyText & "<hr><img src=""" & virtualPath & name & """>"
       End If
     End If
     html = html & "<a href=""" & virtualPath & name & """ target=""_blank"">" & name & "</a> "
   Next
   html = html & "</font><br>"
 End If

'==============================
     oMsg = Nothing
End If
oPOP3.Disconnect
    oPOP3=Nothing
%>
</body>
</html>
Agradezco de antemano su ayuda.
  #2 (permalink)  
Antiguo 26/10/2006, 15:47
Avatar de shumito  
Fecha de Ingreso: mayo-2006
Mensajes: 248
Antigüedad: 18 años
Puntos: 0
No sep pero quizas el
count = oMsg.GetAttachmentCount
quizas tu oMsg no siempre es distinto de null
en todo caso es algo por el estilo yo tenia algo parecido con un griview y era eso a veces era null ...
  #3 (permalink)  
Antiguo 27/10/2006, 09:56
 
Fecha de Ingreso: octubre-2004
Mensajes: 55
Antigüedad: 19 años, 7 meses
Puntos: 0
Cita:
Iniciado por shumito Ver Mensaje
No sep pero quizas el
count = oMsg.GetAttachmentCount
quizas tu oMsg no siempre es distinto de null
en todo caso es algo por el estilo yo tenia algo parecido con un griview y era eso a veces era null ...
Gracias amigo ya lo solucioné...

En realidad el error se encontraba en:

Código:
oMsg.GetAttachmentName(i).toString
Simplemente eliminé el .ToString

En fin, los misterios del .Net

Un saludo.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:21.