Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Access -> .txt -> mail

[es] :: Access :: Access -> .txt -> mail

[ Pregleda: 2193 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

sule99
student

Član broj: 227708
Poruke: 93
*.adsl.net.t-com.hr.



+1 Profil

icon Access -> .txt -> mail14.09.2010. u 07:57 - pre 164 meseci
Imam jednu formu i na nju bi postavio button na koji bi se klikom kreirao .txt/.csv fajl i automatski se nakon toga slao mailom na 2 ili tri adrese. Da li je ovo izvedivo i kako?

za kreiranje txt fajla mislim da mi može poslužiti sljedeći kod

Code:
DoCmd.TransferText acExportDelim, "Export CSV", "tblTemp", "C:\Cenovnici\" & [Naziv] & ".csv", True


e sada, šta bi još trebalo,ako se može, dodati da rezultat ovog exporta salje na mail...

 
Odgovor na temu

smal
Slobodan Maljković
Kragujevac, Srbija

Član broj: 228672
Poruke: 286
*.static.sbb.rs.



+13 Profil

icon Re: Access -> .txt -> mail14.09.2010. u 10:31 - pre 164 meseci
Koliko je meni poznato, neka me neko ispravi ako grešim, iz Accessa možeš poslati preko e-mail klijenta neki njegov objekat (query, table, report...), i to u podržanim formatima: ASP, DAP, HTML, IIS, SNP, TXT, XLS i PDF i XPS u 2007 i novijim verzijama.

Nije moguće iz "suvog" Accessa poslati neki eksterni attachment, bar ne bez nekih pomoćnih programa (SMTP server i sl.), a mislim i da CSV nije podržan.

Ako ti ova ograničenja ne smetaju, onda prvo napravi jedan modul sa funkcijom koja čita tabelu sa e-mail adresama, i postavlja ih jednu za drugom u listu za ispis u To polje e-mail klijenta:
Code:
Function Ispis() As String
Dim rst As New ADODB.Recordset
 
    
   rst.Open "SELECT email FROM tblAdrese", CurrentProject.Connection, adOpenStatic, adLockReadOnly
    If rst.RecordCount > 0 Then Ispis = rst.GetString(adClipString, , , "; ")

    rst.Close

    Ispis = Left(Ispis, Len(Ispis) - 1)
    

End Function


A onda na formi napravi dugme za slanje, gde na OnClick otprilike stoji ovo:
Code:

Private Sub SendMail_Click()
On Error GoTo Err_SendMail_Click

DoCmd.SendObject _
    acSendTable, _
    "Cenovnici", _
    acFormatTXT, _
    Ispis(), _
    , _
    , _
    "Naslov poruke", _
    "Tekst u telu poruke.", _
    True

Exit_Err_SendMail_Click:
    Exit Sub

Err_SendMail_Click:
    MsgBox "Poruka nije poslata!", vbInformation, "Obaveštenje"
    Resume Exit_Err_SendMail_Click

 
Odgovor na temu

banem
Kikinda

Član broj: 16619
Poruke: 583
*.dynamic.sbb.rs.



+15 Profil

icon Re: Access -> .txt -> mail14.09.2010. u 10:39 - pre 164 meseci
Ako koristiš puni Outlook ili bilo koji drugi koji podržava objektni model, moguće je, čak je prilično jednostavno. Naravno da se iz Accessa može dobiti CSV. Ako šalješ samo jedan fajl uvek, možeš ovo dole preraditi da putanju i naziv fajla uzima funkcija kao parametar:

Code:

Public strAttachment(1 To 100) As String

Public Function SendOutlookMessage( _
    bolSendSave As Boolean, _
    strEmailAddress As String, _
    strEmailCCAddress As String, _
    strSubject As String, _
    strMessage As String, _
    blnDisplayMessage As Boolean, _
    Optional strEmailBCCAddress As String)

'This subroutine sends an e-mail message through
'MS Outlook. If the "blnDisplayMessage" parm is
'set to "False", the message is placed in the
'Outlook Outbox. "True" displays the message, and
'user will have to click "Send" to send it.
    
Dim objApp As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecipient As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim blnOutlookInitiallyOpen As Boolean
Dim strProcName As String
Dim rst As DAO.Recordset
Dim strFile As String
Dim x As Integer

x = 1

'On Error Resume Next
strProcName = "SendOutlookMessage"

blnOutlookInitiallyOpen = True
'Set objApp = GetObject(, "Outlook.Application")
Set objApp = CreateObject("Outlook.Application")

If Err <> 0 Then Beep: _
    MsgBox "Error in " & strProcName & " (1): " _
        & Err.Number & " - " & Err.Description: _
    Err.Clear: _
    GoTo Exit_Section

'Create the message
Set objOutlookMsg = objApp.CreateItem(olMailItem)
If Err <> 0 Then Beep: _
    MsgBox "Error in " & strProcName & " (2): " _
        & Err.Number & " - " & Err.Description: _
    Err.Clear: _
    GoTo Exit_Section
    
With objOutlookMsg
    Set objOutlookRecipient = .Recipients.Add(strEmailAddress)
    objOutlookRecipient.Type = olTo
    If strEmailCCAddress = "" Then
    Else
        Set objOutlookRecipient = .Recipients.Add(strEmailCCAddress)
        objOutlookRecipient.Type = olCC
    End If
    If strEmailBCCAddress = "" Then
    Else
        Set objOutlookRecipient = .Recipients.Add(strEmailBCCAddress)
        objOutlookRecipient.Type = olBCC
    End If
    .Subject = strSubject
    .HTMLBody = "<html><body> " & strMessage & " </body></html>"
    '.Body = strMessage

    '* Add attachments
    'Set rst = CurrentDb.OpenRecordset(strTable)
    'If Not rst.EOF Then
    '    rst.MoveFirst
    '    Do While Not rst.EOF
    '        strFile = rst.Fields(0)
    '        If Len(strFile) > 0 Then
    Do While strAttachment(x) <> ""
        Set objOutlookAttach = .Attachments.Add(strAttachment(x))
        x = x + 1
    Loop
                
    '        End If
    '        rst.MoveNext
    '    Loop
    'End If
    Set rst = Nothing

    If blnDisplayMessage Then
        .Display
    Else
        '* Send message by putting it in the Outbox
        If bolSendSave = True Then
            .Send
        Else
           .Save
        End If
    End If
End With
    
If Err <> 0 Then Beep: _
    MsgBox "Error in " & strProcName & " (99): " _
        & Err.Number & " - " & Err.Description: _
    Err.Clear: _
    GoTo Exit_Section
    
Exit_Section:
    On Error Resume Next
    If Not blnOutlookInitiallyOpen Then
       objApp.Quit
    End If
    Set objApp = Nothing
    Set objOutlookMsg = Nothing
    Set objOutlookAttach = Nothing
    Set objOutlookRecipient = Nothing
    On Error GoTo 0
End Function

Pozdrav,
Branislav
 
Odgovor na temu

sule99
student

Član broj: 227708
Poruke: 93
*.adsl.net.t-com.hr.



+1 Profil

icon Re: Access -> .txt -> mail14.09.2010. u 10:55 - pre 164 meseci
Hvala obojici na odgovorima, pogledat ću i potruditi se napraviti tako. pozdrav
 
Odgovor na temu

[es] :: Access :: Access -> .txt -> mail

[ Pregleda: 2193 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.