Results 1 to 7 of 7

Thread: Copy data and send in outlook email
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    May 2014
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Copy data and send in outlook email

    Hi,

    Could you please help m with a VBA code to cop data from excel and send in an email.

    Thanks

  2. #2
    New Member
    Join Date
    May 2014
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Copy data and send in outlook email

    Hello

    Add to the ThisWorkBook section;

    Code:
    Private Sub Workbook_BeforeClose(Cancel As Boolean)If MsgBox("Çalışma kitabı ekli olarak belirttiğiniz adrese gönderilsin mi?", vbQuestion + vbYesNo, "MAİL") = vbYes Then
        If Saved = False Then Saved = True
    Dim OutApp As Object
        Dim OutMail As Object
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
        On Error Resume Next
        With OutMail
            .To = "xxx@xmail.com" 'Posta gönderilecek adres
            .CC = "" '(Carbon Copy) Bu şekilde eklediğiniz kişilere mailin bir kopyası gider.
            .BCC = "" '(Blind Carbon Copy). Bu şekilde eklediğiniz kişilere de mail gider ancak Gönderilen ve CC kısmına yazdığınız kişilerin bundan haberi olmaz.
            .Subject = "Dosyalarınız Yedeklenmiştir." ' Konu (Title)
            .Body = "Dosyalarınız Yedeklenmiştir." 'Yazmak istedikleriniz. (Prompt)
            .Attachments.Add ActiveWorkbook.FullName 'Bu çalışma kitabını ek olarak gönder.
            '.Attachments.Remove (1) 'Ek göndermek istemezsen
            '.Attachments.Add ("C:\test.txt") şeklinde de dosya eklenebilir.
            .Send  'yada .Send veya Display kullanılır.
        End With
        On Error GoTo 0
        Set OutMail = Nothing
        Set OutApp = Nothing
    End If
    End Sub

  3. #3
    New Member
    Join Date
    May 2014
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Copy data and send in outlook email

    What does below mean-

    ("Çalışma kitabı ekli olarak belirttiğiniz adrese gönderilsin mi?", vbQuestion + vbYesNo, "MAİL") 'Posta gönderilecek adres
    Bu şekilde eklediğiniz kişilere mailin bir kopyası gider.
    Bu şekilde eklediğiniz kişilere de mail gider ancak Gönderilen ve CC kısmına yazdığınız kişilerin bundan haberi olmaz.
    .Subject = "Dosyalarınız Yedeklenmiştir." ' Konu (Title)
    .Body = "Dosyalarınız Yedeklenmiştir." 'Yazmak istedikleriniz. (Prompt)
    çalışma kitabını ek olarak gönder.
    'Ek göndermek istemezsen
    şeklinde de dosya eklenebilir.
    'yada .

    Please advise.

  4. #4
    New Member
    Join Date
    May 2014
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Copy data and send in outlook email

    Code:
    Private Sub Workbook_BeforeClose(Cancel As Boolean)If MsgBox("Do you want to sent e-mail this work book?", vbQuestion + vbYesNo, "MAİL") = vbYes Then    If Saved = False Then Saved = TrueDim OutApp As Object    Dim OutMail As Object    Set OutApp = CreateObject("Outlook.Application")    Set OutMail = OutApp.CreateItem(0)    On Error Resume Next    With OutMail        .To = "xxx@xmail.com" 'Define here to your or anyone E-mail address where do you want to send it.        .CC = "" '(Carbon Copy) If you add e-mails like that, than will be gone a copy e-mail another peoples.        .BCC = "" '(Blind Carbon Copy). 'Ghost e-mail address, if you are using outlook, u know allways this subjects..        .Subject = "files are backed up" ' Konu (Title)        .Body = "files are backed up." 'If you want anything your message with e-mail, you will write from here. That will be sent automatically alltimes. (Prompt)
            .Attachments.Add ActiveWorkbook.FullName 'Sent this workbook like a additional.        '.Attachments.Remove (1) 'If you dont like additional.        '.Attachments.Add ("C:\test.txt") can be add a file like that.        .Send  'or .Send or Display can be use.    End With    On Error GoTo 0    Set OutMail = Nothing    Set OutApp = NothingEnd IfEnd Sub

  5. #5
    New Member
    Join Date
    May 2014
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Copy data and send in outlook email

    Hi,
    Thanks a lot.
    This was very useful.
    But I want a code where the data should be copied from excel to outlook body not as an attachment.
    Also before the mail is sent I want to see the drafted mail.
    Then a msg should appear where when I say ok only then mail should be sent.
    Thanks,

  6. #6
    New Member
    Join Date
    May 2014
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Copy data and send in outlook email

    Hi,
    Thanks a lot.
    This was very useful.
    But I want a code where the data should be copied from excel to outlook body not as an attachment.
    Also before the mail is sent I want to see the drafted mail.
    Then a msg should appear where when I say ok only then mail should be sent.
    Thanks,

  7. #7
    New Member
    Join Date
    May 2014
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Copy data and send in outlook email

    Hi there,

    Can anyone please help me with a code where the data should be copied from excel to outlook body not as an attachment.
    Also before the mail is sent I want to see the drafted mail.
    Then a msg should appear where when I say ok only then mail should be sent.
    Thanks,

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •