Invio di dati Excel


3

Vorrei inviare un messaggio di posta elettronica a molti utenti allegandovi alcuni dati personali, come le password, che non possono essere inviati ad altri.

Gli utenti e i dati personali sono organizzati su colonne in un file Excel.

Vorrei inviare automaticamente un'e-mail a ciascun utente in base a quel file, ovvero un messaggio per ogni riga e utilizzando un determinato modello di messaggio.

Nel menu di Excel, non sono riuscito a trovare tale opzione ...

Qualsiasi aiuto?

Per esempio:

Data.xls

Recipient   Password
a@a.com fjsdjg
b@a.com kjasdh
c@a.com laldwk
d@a.com kdfljf

Modello corpo messaggio e-mail:

Hello friends!

I created a survey on Google Docs named "XXX", with the
following link: http://XXX

To avoid double submitting or answers from people out of
our group, I created a password below for you. Please,
enter that on related field to validate your form.

######

Bye,
Me

Quale programma di posta elettronica usi? O forse ancora più importante, come si invia l'e-mail utilizzando il proprio indirizzo e-mail? SMTP è supportato?
allquixotic,

@allquixotic Posso usare qualsiasi gestore di posta elettronica gratuito. Mi consigliate uno per me? Ho molti indirizzi con supporto SMTP, ma posso crearne uno a tale scopo.
Kokbira,

Risposte:


1

Il modo migliore per farlo è con la funzionalità "Stampa unione" in Microsoft Word nella scheda indirizzi. Ciò ti consentirà di inviare un messaggio agli indirizzi e-mail elencati sul foglio di calcolo, in quanto ti dà la possibilità di selezionare un foglio di calcolo per cui estrarre le informazioni per la stampa unione.


Se ho 500 indirizzi di destinatari penso che passerà molto tempo. Sto cercando un modo più automatico, come fare alcuni clic del mouse non correlati alla quantità del destinatario per inviare le e-mail ... Se faccio come mi hai suggerito, devo ripetere quella procedura 500 volte ..
kokbira

questo è ciò per cui viene utilizzata la stampa unione. Passerà attraverso le e-mail elencate sul foglio di calcolo e invierà loro lo stesso modello con le informazioni specifiche che hai selezionato per ogni utente da vedere. Il massimo a cui abbia mai inviato una stampa unione è di circa 700 persone, ma ci sono voluti solo un minuto o due perché ciò avvenga.
Jared,

Bello. Lo proverò oggi.
Kokbira,

la procedura guidata di stampa unione è il modo più semplice, ti guida passo dopo passo.
Jared,

1

Puoi anche farlo da VBA utilizzando Microsoft Outlook (oppure puoi sostituire la funzione SendEmail nel codice con qualsiasi altra implementazione di invio di posta che desideri). Basta aprire la scheda Sviluppatore, Visual Basic e inserirla nel modulo ThisWorkbook.

Option Explicit

Public Mail_Object As Object

Sub SU_458659()
    Dim numofrows As Integer
    Dim i As Integer
    Dim ws As Worksheet
    Dim startRow As Integer
    Dim emailColumn As Integer
    Dim passwordColumn As Integer

    'TWEAKABLE: Change this to the first row to process
    startRow = 2 'Assuming row 1 is header

    'TWEAKABLE: Change ActiveSheet to a sheet name, etc. if you don't want it to run on the currently "active" (selected) sheet
    Set ws = ActiveSheet

    'TWEAKABLE: Change this to the row number ("A" is 1) of the email address
    emailColumn = 1

    'TWEAKABLE: Change this to the row number ("B" is 2) of the password field
    passwordColumn = 2

    'Get the number of rows in the sheet
    numofrows = ws.Range("A1").Offset(ws.Rows.Count - 1, 0).End(xlUp).Row

    'Shouldn't have to tweak anything in here
    For i = startRow To numofrows
        Dim emailCell As Range
        Dim passwordCell As Range
        Set emailCell = ws.Cells(i, emailColumn)
        Set passwordCell = ws.Cells(i, passwordColumn)
        If Not IsEmpty(emailCell) Then
            Dim email As String
            Dim password As String
            email = CStr(emailCell.Value)
            password = CStr(passwordCell.Value)
            SendEmail email, password
        End If
    Next i
End Sub

Sub SendEmail(email As String, password As String)
    Dim emailSubject As String
    Dim emailSendFrom As String
    Dim emailCc As String
    Dim emailBcc As String
    Dim prePassword As String
    Dim postPassword As String
    Dim Mail_Single As Variant

    If Mail_Object Is Nothing Then Set Mail_Object = CreateObject("Outlook.Application")

    'TWEAKABLE: Email subject
    emailSubject = "CHANGE THIS"

    'TWEAKABLE: The 'from' email address
    emailSendFrom = "you@example.com"

    'TWEAKABLE: The CC: field (just make it the empty string "" if you don't want a CC
    emailCc = "nobody@example.com"

    'TWEAKABLE: The BCC: field (just make it the empty string "" if you don't want a BCC)
    emailBcc = "nobody@example.com"

    'TWEAKABLE: The email body BEFORE the password
    prePassword = "Your password is: """

    'TWEAKABLE: The email body AFTER the password - vbCrLf is a newline like hitting Enter
    postPassword = """." & vbCrLf & vbCrLf & "Have fun!"

    On Error GoTo debugs
    Set Mail_Single = Mail_Object.CreateItem(0)
    With Mail_Single
    .Subject = emailSubject
    .To = email
    .cc = emailCc
    .BCC = emailBcc
    .Body = prePassword & password & postPassword

    'TWEAKABLE: Remove the following three lines before ".send" to remove message box confirmation
    Dim retval As Variant
    retval = MsgBox("Do you want to send an email to " & email & " with the password " & password & "?", vbYesNo, "Confirmation")
    If retval = vbNo Then Exit Sub

    .send
    End With
debugs:
    If Err.Description <> "" Then MsgBox Err.Description
End Sub

lo
proverò
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.