Showing posts with label email. Show all posts
Showing posts with label email. Show all posts

Monday, March 26, 2012

Strange Error

Hi everyone!
now, i have a small problem. It is not easy to understand with me.
I want to send an email to my email with an attachment. This is my code:
<%@dotnet.itags.org. Page Language="vb" CodeBehind="MailAttachment.aspx.vb" AutoEventWireup="false" Inherits="WebApplication2.MailAttachment" %>
<% @dotnet.itags.org.Import Namespace="System.Web.Mail" %>
<%
dim msgMail as new MailMessage

msgMail.To = "thedoem111@dotnet.itags.org.yahoo.com"
msgMail.From = "tuthanvn84@dotnet.itags.org.yahoo.com"
msgMail.Subject = "Attachment Test"

msgMail.BodyFormat = MailFormat.Text
msgMail.Body = "Check out the attachment!"
msgMail.Attachments.Add(new MailAttachment(Server.MapPath("MyExcel.xls")))
try
SmtpMail.Send(msgMail)

Response.Write("Email was queued to disk")
catch ex as exception
Response.Write(Ex.message)

end try

%>
But I want to use codebehind. They are occur an error at this line:
msgMail.Attachments.Add(new MailAttachment(Server.MapPath("MyExcel.xls")))

I don't understand what really happen. Can anyone tell me what happen?
Thank for any suggesstion!hi,
i do not know what the error u are getting. my guess would be that it is an attachment size error. for this u may want to check the size of the attachments set on ur SMTP server, that u can find on ur IIS server.
if its an other error please post the error .

- gkopparam
hi gkopparam!
the first, It is code, not in runtime.
the second, I had tested. The first code is successful. Then i copy and paste in codebehind file. It occur an error at that line.
1stly, what is the exact error you are getting. A screen shot of the stack trace would be usefull.

Also, what is the string value of:

Server.MapPath("MyExcel.xls")))

Woka
Hi Wokawidget!
I'm sorry if my description is not clearly for you.

So i have two screenshoots here. Can you tell me what my error is?

http://i117.photobucket.com/albums/o50/lekhuyen/FirstCode.jpg

and

http://i117.photobucket.com/albums/o50/lekhuyen/SecondCode.jpg

Best regards!
If you hover of the the squiggley line then .NET will tell you the error, which is Server.MapPath does not exist.

The server object is taken from the page object's base. So if you put that code into an aspx page and not a standard class it will work.

However, I would prefer to keep functions like this in classes, which is good coding, but u will need to replace the Server.MapPath bit with a param that gets passed in, ie

Public Sub SendMail(ByVal recipients As String, ByVal attachmentPath As String)

msg.Attachments.Add(attachmnetPath)

End Sub

Then from the web page it can be called like so:

MyClass.SendMail("Woof@.Woka.com", Server.MapPath("MyFile.woof"))

Woka
Also, little tip with forum posting. Try to take out the email addresses in your screenshot. This forum is thankfully filled with trustworthy folk but the last thing you want is your email adress advertised publicly like this :thumb:
Yea, that's a damn good pt. Woka@.Woof.com was a made up address for this very reason. Spiders and bots trawl these pages and strip out any email addresses it finds so that they can be used for spamming.

Woka
Unfortunately I can't take all the credit as it's mentioned in the "Before you post..." announcement by Brad :D

Saturday, March 24, 2012

Strange Errors...Don't Understand

I recently implemented error processing on my .net website, where I send
myself an email from global.asax on an application error. In the last two
days I have gotten a "The file '/detail.aspx' does not exits" type
error--with two different file names. In both cases, I searched my entire
source for the '/detail.aspx' reference and it doesn't exist.

What could be causing this error? Text of error email I sent to myself
follows...

The file '/detail.aspx' does not exist.

System.Web.HttpException: The file '/detail.aspx' does not exist. at
System.Web.UI.Util.CheckVirtualFileExists(VirtualP ath virtualPath) at
System.Web.Compilation.BuildManager.GetVPathBuildR esultInternal(VirtualPath
virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean
allowBuildInPrecompile) at
System.Web.Compilation.BuildManager.GetVPathBuildR esultWithNoAssert(HttpContext
context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp,
Boolean allowBuildInPrecompile) at
System.Web.Compilation.BuildManager.GetVirtualPath ObjectFactory(VirtualPath
virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) at
System.Web.Compilation.BuildManager.CreateInstance FromVirtualPath(VirtualPath
virtualPath, Type requiredBaseType, HttpContext context, Boolean
allowCrossApp, Boolean noAssert) at
System.Web.UI.PageHandlerFactory.GetHandlerHelper( HttpContext context, String
requestType, VirtualPath virtualPath, String physicalPath) at
System.Web.UI.PageHandlerFactory.System.Web.IHttpH andlerFactory2.GetHandler(HttpContext
context, String requestType, VirtualPath virtualPath, String physicalPath) at
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
at
System.Web.HttpApplication.MapHandlerExecutionStep .System.Web.HttpApplication.IExecutionStep.Execute ()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously)See if this helps :

http://www.velocityreviews.com/foru...-aspnet-20.html
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
======================================
"Paul Buzza, oldster using new tools" <PaulBuzzaoldsterusingnewtools@.discussions.microsof t.comwrote in message
news:9550498C-9323-4D8A-BA54-555CCFE19734@.microsoft.com...

Quote:

Originally Posted by

>I recently implemented error processing on my .net website, where I send
myself an email from global.asax on an application error. In the last two
days I have gotten a "The file '/detail.aspx' does not exits" type
error--with two different file names. In both cases, I searched my entire
source for the '/detail.aspx' reference and it doesn't exist.
>
What could be causing this error? Text of error email I sent to myself
follows...
>
The file '/detail.aspx' does not exist.
>
System.Web.HttpException: The file '/detail.aspx' does not exist. at
System.Web.UI.Util.CheckVirtualFileExists(VirtualP ath virtualPath) at
System.Web.Compilation.BuildManager.GetVPathBuildR esultInternal(VirtualPath
virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean
allowBuildInPrecompile) at
System.Web.Compilation.BuildManager.GetVPathBuildR esultWithNoAssert(HttpContext
context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp,
Boolean allowBuildInPrecompile) at
System.Web.Compilation.BuildManager.GetVirtualPath ObjectFactory(VirtualPath
virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) at
System.Web.Compilation.BuildManager.CreateInstance FromVirtualPath(VirtualPath
virtualPath, Type requiredBaseType, HttpContext context, Boolean
allowCrossApp, Boolean noAssert) at
System.Web.UI.PageHandlerFactory.GetHandlerHelper( HttpContext context, String
requestType, VirtualPath virtualPath, String physicalPath) at
System.Web.UI.PageHandlerFactory.System.Web.IHttpH andlerFactory2.GetHandler(HttpContext
context, String requestType, VirtualPath virtualPath, String physicalPath) at
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
at
System.Web.HttpApplication.MapHandlerExecutionStep .System.Web.HttpApplication.IExecutionStep.Execute ()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously)


Juan,

Thank you. It was the "click" I needed. My old version of my site had the
named files on which I see the errors. If someone had a saved bookmark to
one of my old pages, this is the error I see. All I have to do is handle the
404 error with a separate error page, and tell the originator to update their
bookmarks.

Paul

"Juan T. Llibre" wrote:

Quote:

Originally Posted by

See if this helps :
>
http://www.velocityreviews.com/foru...-aspnet-20.html
>
>
>
>
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
======================================
"Paul Buzza, oldster using new tools" <PaulBuzzaoldsterusingnewtools@.discussions.microsof t.comwrote in message
news:9550498C-9323-4D8A-BA54-555CCFE19734@.microsoft.com...

Quote:

Originally Posted by

I recently implemented error processing on my .net website, where I send
myself an email from global.asax on an application error. In the last two
days I have gotten a "The file '/detail.aspx' does not exits" type
error--with two different file names. In both cases, I searched my entire
source for the '/detail.aspx' reference and it doesn't exist.

What could be causing this error? Text of error email I sent to myself
follows...

The file '/detail.aspx' does not exist.

System.Web.HttpException: The file '/detail.aspx' does not exist. at
System.Web.UI.Util.CheckVirtualFileExists(VirtualP ath virtualPath) at
System.Web.Compilation.BuildManager.GetVPathBuildR esultInternal(VirtualPath
virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean
allowBuildInPrecompile) at
System.Web.Compilation.BuildManager.GetVPathBuildR esultWithNoAssert(HttpContext
context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp,
Boolean allowBuildInPrecompile) at
System.Web.Compilation.BuildManager.GetVirtualPath ObjectFactory(VirtualPath
virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) at
System.Web.Compilation.BuildManager.CreateInstance FromVirtualPath(VirtualPath
virtualPath, Type requiredBaseType, HttpContext context, Boolean
allowCrossApp, Boolean noAssert) at
System.Web.UI.PageHandlerFactory.GetHandlerHelper( HttpContext context, String
requestType, VirtualPath virtualPath, String physicalPath) at
System.Web.UI.PageHandlerFactory.System.Web.IHttpH andlerFactory2.GetHandler(HttpContext
context, String requestType, VirtualPath virtualPath, String physicalPath) at
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
at
System.Web.HttpApplication.MapHandlerExecutionStep .System.Web.HttpApplication.IExecutionStep.Execute ()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously)


>
>
>

Tuesday, March 13, 2012

Strange problem in sending emails by asp.net

I use the following code to send email, and strange thing that I received the message at hotmail mail, and failed to receive it at yahoo mail , can you help me and explain what this happen and how to overcome this.


Regards
Serag Farag
PrivateSub Button1_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles Button1.Click

Dim msgmailAs System.Web.Mail.MailMessage

Dim SmtpMailAs System.Web.Mail.SmtpMail

msgmail =New System.Web.Mail.MailMessage

' SmtpMail =

msgmail.To = "elomah@dotnet.itags.org.yahoo.com"

msgmail.Cc = "ahmed_serageldin@dotnet.itags.org.hotmail.com"

msgmail.From = "ahmed_serageldin@dotnet.itags.org.hotmail.com"

msgmail.Subject = "subject of ggggggggggggggmsg"

msgmail.BodyFormat = System.Web.Mail.MailFormat.Html

msgmail.Body = " what u send mail ofgh ghgf ghr msgs"

SmtpMail.SmtpServer = "serag-0ivd22eow"

smtpmail.send(msgmail)

Response.Write("msg recived")

EndSub

Hello Serag and welcome to the forums.
First of all, if your email is received by Hotmail, then I don't thinkthere is a problem with your code. Maybe some wrong happened on its wayto Yahoo. Try to upload your script to a live server and then send theemail again.
Regards,


i saw the same problem in a diffirent thread i will check if i can find it for you but any way try what bilal suggest

try one of those links it might helps
http://forums.asp.net/916696/ShowPost.aspx
http://forums.asp.net/ShowPost.aspx?PageIndex=2&PostID=719622#719622
http://forums.asp.net/846879/ShowPost.aspx
and let me know if you solve it
good luck !!!