Camera Phone -> Website

OJM

Perch
Hi all,

I was just wondering if anyone's ever come across some code which will allow people to send an image from a camera mobile phone, to an email address, and for an ASP page (or PHP if needed) to display it?

I came across the below code, but after having a quick go at work, it kept throwing up errors (will have to look at home to see what they are - friendly errors are on at work X( );

Code:
 <script language=jscript runat=server>
function y2k(number) { return (number < 1000) ? number + 1900 :
number; }
function milliDif() {
var d = new Date();
return Date.UTC(y2k(d.getYear()),d.getMonth(),d.getDate(),d.getHours(),
d.getMinutes(),d.getSeconds(), d.getMilliseconds())
}
</script>
<%
'*************************************
'Brought to you by Johnny M
'Feel free to change anything you want
'Email suggestions/comments to: [email="[email protected]"][email protected][/email]
'*************************************

'Just change these four variables to your information
youremail = "[color=red]***@***.***[/color]"
yourpassword = "[color=red]***[/color]"
yourmailurl = "[color=red]****.***.***[/color]"
yourdirectory = "[color=red]D:\hshome\***\***\***\[/color]"
 

Set pop3 = Server.CreateObject( "JMail.POP3" )
pop3.Connect youremail, yourpassword, yourmailurl
Function getEmail(x)
if pop3.count > 0 then
Set msg = pop3.Messages.item(x)
  Set Attachments = msg.Attachments
   separator = ", "
  For i = 0 To Attachments.Count - 1
	If i = Attachments.Count - 1 Then
	  separator = ""
	End If
  Set at = Attachments(i)
  If ( InStr(at.Name, "jpg") > 0 OR InStr(at.Name, "gif") > 0 ) Then
 Randomize timer
 randnum = int(rnd * 10000000)
 timeNow = milliDif()
 If right(at.Name, 3) = "jpg" then
  filename = randnum & "-" &  timenow & ".jpg"
 Else
  filename = randnum & "-" &  timenow & ".gif"
 End if
	Dim fso
	Set fso = CreateObject("Scripting.FileSystemObject")
   at.SaveToFile( yourdirectory & at.Name )
	fso.MoveFile yourdirectory & at.Name, yourdirectory & filename
 set fso = nothing
  End if
 Next
 pop3.DeleteSingleMessage x
end if
End Function
 
x = pop3.count
DO UNTIL x = 0
 getemail(x)
x = x - 1
Loop
pop3.Disconnect
%>

I was just wondering if anyone has any tried and tested code?

Cheers all,

Oli
 
This is the message I received with the above code;

Code:
 jmail.POP3 error '8000ffff' 

This function is not included in this version of jmail. 

/test/phone/phone.asp, line 29
 
thats correct on the free version of jmail you aren't able to use the pop3 feature as its disabled.

try aspmail or something simular aspEmail maybe, it has a pop 3 access and also attachments.
 
Ah ok, thanks.

Any idea where I can find some info on how to convert it to make it work with aspmail or aspEmail? I'm not up on things like that, but I'm attempting to learn as much as I can :)
 
unfortently you'll have to completely re-do that code

as you'll have to use AspPOP 3 which is by the people who do AspMail

http://www.serverobjects.com/comp/Asppop3.htm

this isnt limited to Camara Phones, as all its doing is getting an email and its attachment off the server.

like the example code you posted has, its best to check the extention of the file to make sure its an image, as people might try and send you virus's

though in the example, its missing ".jpeg" so id add that

am acctually currently building a Webmail Script for one of my sites and it takes the emails and pritty much adds them to MSSQL and then removes them

it'd be the same cept you just get the attachment and add it to your gallery and then you can delete the message and its attachment from the mail server
 
Scotty,

Any news on the webmail script that you're building? I'm still looking for a suitable script, but can't find anything.

Cheers!

Oli
 
i havent acctually finished my webmail script, but i could give you sum code for it that you could edit

when i get chances i'll post up the code

hows your ASP? as it'll require quite a bit of editin to get to work exactly right for you
 
heres an attachment of my Webmail function

i stripped sum bits out for privacy reasons


you could easily change this to save the attachment to the server and add it to the database
(as i do in my webmail function) if you have a gallery table in the database, you could use the
subject of the email for the title of it

so you know - it deletes the emails off the mail server once its added them to the database

anyways enjoy

PS: if you get any problems, send me a Private Message thru this forum
 

Attachments

  • webmail.txt
    4.1 KB · Views: 74
yeah, its called on the "inbox" page

i get it to add to the database, so its easier to manage
eg searching, sorting etc

as the component orders old > new, i profer new > old

it might still need more work - am far from launching the webmail part of my site
got a forum to build first :(
 
Back
Top