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]
<%
'*************************************
'Brought to you by Johnny M
'Feel free to change anything you want
'Email suggestions/comments to: [email protected]
'*************************************
'Just change these four variables to your information
youremail = “@."
yourpassword = "”
yourmailurl = ".."
yourdirectory = "D:\hshome***"
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
%>
[/CODE]
I was just wondering if anyone has any tried and tested code?
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
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
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