Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12
  1. #1

    Invio mail con allegato

    Buogiorno a tutti.
    Mi è stato chiesto di creare un form e di inviare una mail con i dati che vengono iseriti. Ebbene sono riuscito a fare funzionare il tutto correttamente con la seguente funzione in VB per pagina ASP:

    codice:
    Function sendMail (corpo, destinatario, mittente, oggetto)
    	Dim objOntMail
    	Set objOntMail = Server.CreateObject("CDONTS.Newmail")
    	objOntMail.From = mittente
    	objOntMail.To = destinatario
    	objOntMail.Subject = oggetto
    	objOntMail.MailFormat = 0
    	objOntMail.BodyFormat = 0
    	objOntMail.Body = corpo
    	objOntMail.Send
    
    	Set objOntMail = Nothing
    End Function
    La mail arriva!
    Sempre nella form è possibile fare l'upload di un file CURRICULUM da inviare insieme alla mail...
    Dunque, ecco il problema: Come faccio a rendere il file (preso con l'upload) allegato della mia mail???

    Ciao e grazie!!!

  2. #2

  3. #3
    fraude quello script alla quale ci hai indirizzati è in giapponese VVoVe: !!!! uno con caratteri europei no e??
    ...Se avanzo seguitemi... Se indietreggio uccidetemi...
    BiteFight... arruolati con me e non te ne pentirai

  4. #4

    Grazie

    Ti ringrazio...
    Non ho ancora letto i contenuti, ma penso che saranno pertinenti.
    Nel caso in cui ho problemi, mi rifaccio vivo.

    Grazie ancora.
    Ciao

  5. #5
    Giapponesi???
    Vedo e controllo...

  6. #6
    Utente di HTML.it L'avatar di fraude
    Registrato dal
    Feb 2004
    Messaggi
    2,870
    Originariamente inviato da soundforgers
    fraude quello script alla quale ci hai indirizzati è in giapponese VVoVe: !!!! uno con caratteri europei no e??
    Giapponesi... hai qualche problema di codifica:

    codice:
    <HTML>
    <HEAD>
    <META http-equiv=Content-Type content="text/html; charset=unicode">     
        <%response.buffer=true
        Func = Request("Func")
        	
    	if isempty(Func) then
        		Func = 1
    	end if
    
        Select case Func
    		case 1
        %>
    </HEAD>
    <BODY>
    
    
    <FONT face=Arial color=blue size=4>Select a File 
    to send as attachment.</FONT>      </P>
        		<FORM ENCTYPE="multipart/form-data" ACTION="sendmail.asp?func=2" METHOD=post id=form1 name=form1>
        		<table>
        			<tr><td><FONT face=Arial></FONT>
        			<tr><td><FONT face=Arial>File 
          Name...</FONT></td></tr>
        			<tr><td><INPUT NAME=File1 SIZE=30 TYPE=file>
    </td></tr>
        			<tr><td align=left><input type="submit" value="Send!" ></td></tr>
        			<tr><td></td></tr>
        		</table>
        <%
        
    		case 2
    			ForWriting = 2
        			adLongVarChar = 201
        			lngNumberUploaded = 0
        	
    				'Get binary data from form		
        			noBytes = Request.TotalBytes 
        				binData = Request.BinaryRead (noBytes)
        
    				'convert the binary data to a string
        			Set RST = CreateObject("ADODB.Recordset")
        				LenBinary = LenB(binData)
        	
        					if LenBinary > 0 then
        						RST.Fields.Append "myBinary", adLongVarChar, LenBinary
        							RST.Open
        								RST.AddNew
        									RST("myBinary").AppendChunk BinData
        								RST.Update
        						strDataWhole = RST("myBinary")
        					End If
        
        'Creates a raw data file for with all data sent. Uncomment for debuging.	
        	'Set fso = CreateObject("Scripting.FileSystemObject")
        	'Set f = fso.OpenTextFile(server.mappath(".") & "\raw.txt", ForWriting, True)
        	'f.Write strDataWhole
        	'set f = nothing
        	'set fso = nothing
        
        'get the boundry indicator
        strBoundry = Request.ServerVariables ("HTTP_CONTENT_TYPE")
        lngBoundryPos = instr(1,strBoundry,"boundary=") + 8 
        strBoundry = "--" & right(strBoundry,len(strBoundry)-lngBoundryPos)
        
        'Get first file boundry positions.
        lngCurrentBegin = instr(1,strDataWhole,strBoundry)
        lngCurrentEnd = instr(lngCurrentBegin + 1,strDataWhole,strBoundry) - 1
    
    do while lngCurrentEnd > 0
    			'Get the data between current boundry and remove it from the whole.
    			strData = mid(strDataWhole,lngCurrentBegin, lngCurrentEnd - lngCurrentBegin)
    				strDataWhole = replace(strDataWhole,strData,"")
        			
    			'Get the full path of the current file.
        		lngBeginFileName = instr(1,strdata,"filename=") + 10
        			lngEndFileName = instr(lngBeginFileName,strData,chr(34)) 
        
    			'Make sure they selected at least one file.	
        		if lngBeginFileName = lngEndFileName and lngNumberUploaded = 0 then
        	
        			Response.Write "<h2> The following error occured.</h2>"
        			Response.Write "You must select at least one file to upload"
        			Response.Write "
    
    Hit the back button, make the needed corrections and resubmit your information."
        			Response.Write "
    
    <input type='button' onclick='history.go(-1)' value='<< Back' id='button'1 name='button'1>"
        			Response.End 
        	
        		end if
        
    			'There could be one or more empty file boxes.	
        		strFilename = mid(strData,lngBeginFileName,lngEndFileName - lngBeginFileName)
        
    			'Creates a raw data file with data between current boundrys. Uncomment for debuging.	
        		'Set fso = CreateObject("Scripting.FileSystemObject")
        		'Set f = fso.OpenTextFile(server.mappath(".") & "\raw_" & lngNumberUploaded & ".txt", ForWriting, True)
        		'f.Write strData
        		'set f = nothing
        		'set fso = nothing
        		
    			'Loose the path information and keep just the file name.	
        		tmpLng = instr(1,strFilename,"\")
        			
        			do while tmpLng > 0
        				PrevPos = tmpLng
        				tmpLng = instr(PrevPos + 1,strFilename,"\")
        			loop
        		
        				FileName = right(strFilename,len(strFileName) - PrevPos)
        	
    			'Get the begining position of the file data sent.
    			'if the file type is registered with the browser then there will be a Content-Type
        			lngCT = instr(1,strData,"Content-Type:")
        	
        				if lngCT > 0 then
        					lngBeginPos = instr(lngCT,strData,chr(13) & chr(10)) + 4
        						
        						else
        			 				lngBeginPos = lngEndFileName
        				end if
        
    			'Get the ending position of the file data sent.
        		lngEndPos = len(strData) 
        		
    			'Calculate the file size.	
        		lngDataLenth = lngEndPos - lngBeginPos
    				'Get the file data	
        			strFileData = mid(strData,lngBeginPos,lngDataLenth)
    				
    				' Create the file, change the path to the path U use for temp storage of the file
    				' make sure you have the IUSR_YOURCOMPUTER granted WRITE access to the uploads dir
        			Set fso = CreateObject("Scripting.FileSystemObject")
        				Set f = fso.OpenTextFile(server.mappath("../fileupload/uploads") & "\" & FileName, ForWriting, True)
        					f.Write strFileData
        
    						' Get full Path, you need it for deleting the file later  	
        					Dim ThisFile
        				ThisFile = server.MapPath("../fileupload/uploads") & "/" & filename
        
           			lngNumberUploaded = lngNumberUploaded + 1
        		
        		' destroy f, free memory
      		    set f = nothing
       			
    		'Get then next boundry postitions if any
       		lngCurrentBegin = instr(1,strDataWhole,strBoundry)
    	    lngCurrentEnd = instr(lngCurrentBegin + 1,strDataWhole,strBoundry) - 1
    loop
        	
        ' CDO mail object
        Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
        
        ' CDO mail setttings
    		with objCDOMail
    			.Body = "TestMailtje met attachment!"
    			.Subject = "testing 123"
    			.From = "youraspwebapp@withattachment.com"
    			.To = "Jeroen@trylogical.com"
    			'.Cc = strCC				
    			.MailFormat = 0			
    			.AttachFile ThisFile
    			.Send
    		end with
    	
    	' destroy object, free memory
    	set objCDOMail = nothing
        
        ' Now the file in the uploads dir can be deleted
        fso.DeleteFile ThisFile
        
        ' Destroy FileSystemObject, Free memory
        set fso = nothing
            		
        		Response.Write "Uw mail is verstuurd!</h2>"
        		Response.Write "
    
    <input type='button' onclick='document.location=" & chr(34) & "sendmail.asp" & chr(34) & "' value='<< Back' id='button'1 name='button'1>"	 						
        	
    end select	
        
      
        %></FORM>
        </BODY>
        </HTML>

  7. #7
    Sembra un tantino complessa la cosa.
    Adesso me la stampo e me la studio.

    Grazieeeeee!

  8. #8
    Utente di HTML.it L'avatar di fraude
    Registrato dal
    Feb 2004
    Messaggi
    2,870
    Originariamente inviato da manu.aretuseo
    Si!!!I catatteri sono giapponesi, non riesco a leggere nulla...
    Mannaggia.
    Ho postato lo script così come lo leggo sul mio pc....

  9. #9
    Grazie Fraude

  10. #10
    ma se io volessi inviare un'immagine al mio cliente da visualizzare nella mail, ad esempio un logo o cose del genere come dovrei procedere?
    più che altro cosa dovrei inserire nell'src="" ?
    ...Se avanzo seguitemi... Se indietreggio uccidetemi...
    BiteFight... arruolati con me e non te ne pentirai

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.