Visualizzazione dei risultati da 1 a 7 su 7

Discussione: Vb.... Invio Mail

  1. #1

    Vb.... Invio Mail

    Ciao a tutti
    ho scaricato un file che mi permette di inviare delle mail.
    Vorrei sapere da voi se è possibile inviare nel testo del messaggio una pagina html.
    ho provato ma spedisce il testo html e non mi forma la pagina....


    Come posso Fare??
    Grazie Sara

  2. #2
    Utente di HTML.it L'avatar di sebamix
    Registrato dal
    Aug 2000
    Messaggi
    1,028
    Di che oggetto si tratta?
    Dove lo hai trovato?
    Di oggetti che mandano mail ce ne sono a bizzeffe...
    Comunque con PHP basta modificare il content-type negli header della mail...
    Ti posto un esempio:
    Codice PHP:
    $headers="MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\nFrom: pippo\r\nReply-To: ".$to."X-Mailer: PHP/".phpversion(); 

  3. #3

    grazie

    Ciao..

    PHP però non mi serve....a me serve farlo con VB.


    al posto di un testo io devo nadare una pag web...non il lin...la pagina proprio....

    con outlook ad esempio la mia mail nel riquadro anteprima visualizzerebbe una pag WEB...

  4. #4
    Utente bannato
    Registrato dal
    Jan 2002
    Messaggi
    413
    E come fai amandare email con VB? Me lo spieghi?

  5. #5

    ecco il codice

    FORM

    Private Enum SMTP_State
    MAIL_CONNECT
    MAIL_HELO
    MAIL_FROM
    MAIL_RCPTTO
    MAIL_DATA
    MAIL_DOT
    MAIL_QUIT
    End Enum

    Private m_State As SMTP_State
    Private m_strEncodedFiles As String
    '

    Private Sub cmdAddFile_Click()
    Dim varFilePath As Variant
    Dim strMyDocs As String
    strMyDocs = GetSpecialFolderLocation(Me.hWnd)
    varFilePath = CommFileDialog(strMyDocs, , , , , "File to attach", Me.hWnd)
    If Not IsNull(varFilePath) Then lstAttachments.AddItem CStr(varFilePath)
    End Sub

    Private Sub cmdClose_Click()

    Unload Me

    End Sub

    Private Sub cmdNew_Click()

    txtRecipient = ""
    txtSubject = ""
    txtMessage = ""

    End Sub

    Private Sub cmdRemove_Click()

    On Error Resume Next

    lstAttachments.RemoveItem lstAttachments.ListIndex

    End Sub

    Private Sub cmdSend_Click()
    '
    Dim i As Integer
    Dim strServer As String, ColonPos As Integer, lngPort As Long
    '
    'prepare attachments
    '
    For i = 0 To lstAttachments.ListCount - 1
    'lstAttachments.ListIndex = i
    m_strEncodedFiles = m_strEncodedFiles & _
    UUEncodeFile(lstAttachments.List(i)) & vbCrLf
    Next i
    txtHost.Text = "smtp.aruba.it"
    strServer = Trim(txtHost)
    'find out if the sender is using a Proxy server
    ColonPos = InStr(strServer, ":")
    If ColonPos = 0 Then
    'no proxy so use standard SMTP port
    Winsock1.Connect strServer, 25
    Else
    'Proxy, so get proxy port number and parse out the server name or IP address
    lngPort = CLng(Right$(strServer, Len(strServer) - ColonPos))
    strServer = Left$(strServer, ColonPos - 1)
    Winsock1.Connect strServer, lngPort
    End If
    m_State = MAIL_CONNECT
    '
    End Sub

    Private Sub Form_Load()
    '
    'clear all textboxes
    '
    For Each ctl In Me.Controls
    If TypeOf ctl Is TextBox Then
    ctl.Text = ""
    End If
    Next
    '
    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    Set m_colAttachments = Nothing
    End Sub

    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

    Dim strServerResponse As String
    Dim strResponseCode As String
    Dim strDataToSend As String
    '
    'Retrive data from winsock buffer
    '
    Winsock1.GetData strServerResponse
    '
    Debug.Print strServerResponse
    '
    'Get server response code (first three symbols)
    '
    strResponseCode = Left(strServerResponse, 3)
    '
    'Only these three codes tell us that previous
    'command accepted successfully and we can go on
    '
    If strResponseCode = "250" Or _
    strResponseCode = "220" Or _
    strResponseCode = "354" Then

    Select Case m_State
    Case MAIL_CONNECT
    'Change current state of the session
    m_State = MAIL_HELO
    '
    'Remove blank spaces
    strDataToSend = Trim$(txtSender)
    '
    'Retrieve mailbox name from e-mail address
    strDataToSend = Left$(strDataToSend, _
    InStr(1, strDataToSend, "@") - 1)
    'Send HELO command to the server
    Winsock1.SendData "HELO " & strDataToSend & vbCrLf
    '
    Debug.Print "HELO " & strDataToSend
    '
    Case MAIL_HELO
    '
    'Change current state of the session
    m_State = MAIL_FROM
    '
    'Send MAIL FROM command to the server
    Winsock1.SendData "MAIL FROM:" & Trim$(txtSender) & vbCrLf
    '
    Debug.Print "MAIL FROM:" & Trim$(txtSender)
    '
    Case MAIL_FROM
    '
    'Change current state of the session
    m_State = MAIL_RCPTTO
    '
    'Send RCPT TO command to the server
    Winsock1.SendData "RCPT TO:" & Trim$(txtRecipient) & vbCrLf
    '
    Debug.Print "RCPT TO:" & Trim$(txtRecipient)
    '
    Case MAIL_RCPTTO
    '
    'Change current state of the session
    m_State = MAIL_DATA
    '
    'Send DATA command to the server
    Winsock1.SendData "DATA" & vbCrLf
    '
    Debug.Print "DATA"
    '
    Case MAIL_DATA
    '
    'Change current state of the session
    m_State = MAIL_DOT
    '
    'So now we are sending a message body
    'Each line of text must be completed with
    'linefeed symbol (Chr$(10) or vbLf) not with vbCrLf - This is wrong, it should be vbCrLf
    'see http://cr.yp.to/docs/smtplf.html for details
    '
    'Send Subject line
    Winsock1.SendData "From:" & txtSenderName & " <" & txtSender & ">" & vbCrLf
    Winsock1.SendData "To:" & txtRecipientName & " <" & txtRecipient & ">" & vbCrLf

    '
    Debug.Print "Subject: " & txtSubject
    '
    If Len(txtReplyTo.Text) > 0 Then
    Winsock1.SendData "Subject:" & txtSubject & vbCrLf
    Winsock1.SendData "Reply-To:" & txtReplyToName & " <" & txtReplyTo & ">" & vbCrLf & vbCrLf
    Else
    Winsock1.SendData "Subject:" & txtSubject & vbCrLf & vbCrLf
    End If
    'Dim varLines() As String
    'Dim varLine As String
    Dim strMessage As String
    'Dim i
    '
    'Add atacchments
    strMessage = txtMessage & vbCrLf & vbCrLf & m_strEncodedFiles
    'clear memory
    m_strEncodedFiles = ""
    'Debug.Print Len(strMessage)
    'These lines aren't needed, see
    '
    'http://cr.yp.to/docs/smtplf.html for details
    '
    '*****************************************
    'Parse message to get lines (for VB6 only)
    'varLines() = Split(strMessage, vbNewLine)
    'Parse message to get lines (for VB5 and lower)
    'SplitMessage strMessage, varLines()
    'clear memory
    'strMessage = ""
    '
    'Send each line of the message
    'For i = LBound(varLines()) To UBound(varLines())
    ' Winsock1.SendData varLines(i) & vbCrLf
    ' '
    ' Debug.Print varLines(i)
    'Next
    '
    '******************************************
    Winsock1.SendData strMessage & vbCrLf
    strMessage = ""
    '
    'Send a dot symbol to inform server
    'that sending of message comleted
    Winsock1.SendData "." & vbCrLf
    '
    Debug.Print "."
    '
    Case MAIL_DOT
    'Change current state of the session
    m_State = MAIL_QUIT
    '
    'Send QUIT command to the server
    Winsock1.SendData "QUIT" & vbCrLf
    '
    Debug.Print "QUIT"
    Case MAIL_QUIT
    '
    'Close connection
    Winsock1.Close
    '
    End Select

    Else
    '
    'If we are here server replied with
    'unacceptable respose code therefore we need
    'close connection and inform user about problem
    '
    Winsock1.Close
    '
    If Not m_State = MAIL_QUIT Then
    MsgBox "SMTP Error: " & strServerResponse, _
    vbInformation, "SMTP Error"
    Else
    MsgBox "Message sent successfuly.", vbInformation
    End If
    '
    End If

    End Sub

    Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)

    MsgBox "Winsock Error number " & Number & vbCrLf & _
    Description, vbExclamation, "Winsock Error"

    End Sub


    Private Sub SplitMessage(strMessage As String, strlines() As String)
    Dim intAccs As Long
    Dim i
    Dim lngSpacePos As Long, lngStart As Long
    strMessage = Trim$(strMessage)
    lngSpacePos = 1
    lngSpacePos = InStr(lngSpacePos, strMessage, vbNewLine)
    Do While lngSpacePos
    intAccs = intAccs + 1
    lngSpacePos = InStr(lngSpacePos + 1, strMessage, vbNewLine)
    Loop
    ReDim strlines(intAccs)
    lngStart = 1
    For i = 0 To intAccs
    lngSpacePos = InStr(lngStart, strMessage, vbNewLine)
    If lngSpacePos Then
    strlines(i) = Mid(strMessage, lngStart, lngSpacePos - lngStart)
    lngStart = lngSpacePos + Len(vbNewLine)
    Else
    strlines(i) = Right(strMessage, Len(strMessage) - lngStart + 1)
    End If
    Next
    End Sub

  6. #6
    Utente bannato
    Registrato dal
    Jan 2002
    Messaggi
    413
    Tutta sta roba per una semplice email .. ? Cmq grazie lo provero

  7. #7
    Utente di HTML.it L'avatar di sebamix
    Registrato dal
    Aug 2000
    Messaggi
    1,028
    Dove fai:
    codice:
    Winsock1.SendData "Subject:" & txtSubject & vbCrLf
    Prova ad aggiungere:
    codice:
    Winsock1.SendData "Content-type: text/html; charset=iso-8859-1" & vbCrLf
    Il mio voleva essere un semplice esempio su quale header dovevi impostare, poi non sapendo che codice tu usavi ho postato l'unico esempio a mia disposizione, in PHP.

    Ah, la prossima volta usa i tag code, così il codice viene indentato

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 © 2024 vBulletin Solutions, Inc. All rights reserved.