how do you send email from R











up vote
46
down vote

favorite
16












I want to send emails from R. This is what I have so far:



library(sendmailR)


from <- "eamil@example.com"
to <- "email2@example.com"
subject <- "Performance Result"
body <- "This is the result of the test:"
mailControl=list(smtpServer="snmpt server address")

sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)


When I execute this script, my R session hangs. Any ideas what might be happening?










share|improve this question




















  • 1




    It would be awesome know how to solve this problem I always got error trying to use this function @user1471980
    – Duck
    May 1 '14 at 18:08






  • 1




    what's your operating system?
    – Matthew Plourde
    May 1 '14 at 18:25










  • Does mailR work using the same config?
    – lukeA
    May 1 '14 at 18:30










  • You need to set a valid smtpServer and valid email address in to. Not to mention that this is a duplicate stackoverflow.com/questions/2885660/…
    – David Arenburg
    May 1 '14 at 19:15










  • @Duck sure it works on Windows or any other operating system, you just need an SMTP somewhere, probably not on your machine running R. E.g. you can use your ISP's mail server.
    – daroczig
    May 5 '14 at 21:34















up vote
46
down vote

favorite
16












I want to send emails from R. This is what I have so far:



library(sendmailR)


from <- "eamil@example.com"
to <- "email2@example.com"
subject <- "Performance Result"
body <- "This is the result of the test:"
mailControl=list(smtpServer="snmpt server address")

sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)


When I execute this script, my R session hangs. Any ideas what might be happening?










share|improve this question




















  • 1




    It would be awesome know how to solve this problem I always got error trying to use this function @user1471980
    – Duck
    May 1 '14 at 18:08






  • 1




    what's your operating system?
    – Matthew Plourde
    May 1 '14 at 18:25










  • Does mailR work using the same config?
    – lukeA
    May 1 '14 at 18:30










  • You need to set a valid smtpServer and valid email address in to. Not to mention that this is a duplicate stackoverflow.com/questions/2885660/…
    – David Arenburg
    May 1 '14 at 19:15










  • @Duck sure it works on Windows or any other operating system, you just need an SMTP somewhere, probably not on your machine running R. E.g. you can use your ISP's mail server.
    – daroczig
    May 5 '14 at 21:34













up vote
46
down vote

favorite
16









up vote
46
down vote

favorite
16






16





I want to send emails from R. This is what I have so far:



library(sendmailR)


from <- "eamil@example.com"
to <- "email2@example.com"
subject <- "Performance Result"
body <- "This is the result of the test:"
mailControl=list(smtpServer="snmpt server address")

sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)


When I execute this script, my R session hangs. Any ideas what might be happening?










share|improve this question















I want to send emails from R. This is what I have so far:



library(sendmailR)


from <- "eamil@example.com"
to <- "email2@example.com"
subject <- "Performance Result"
body <- "This is the result of the test:"
mailControl=list(smtpServer="snmpt server address")

sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)


When I execute this script, my R session hangs. Any ideas what might be happening?







r






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 12 '15 at 6:25









isomorphismes

4,91184061




4,91184061










asked May 1 '14 at 16:44









user1471980

3,8382493164




3,8382493164








  • 1




    It would be awesome know how to solve this problem I always got error trying to use this function @user1471980
    – Duck
    May 1 '14 at 18:08






  • 1




    what's your operating system?
    – Matthew Plourde
    May 1 '14 at 18:25










  • Does mailR work using the same config?
    – lukeA
    May 1 '14 at 18:30










  • You need to set a valid smtpServer and valid email address in to. Not to mention that this is a duplicate stackoverflow.com/questions/2885660/…
    – David Arenburg
    May 1 '14 at 19:15










  • @Duck sure it works on Windows or any other operating system, you just need an SMTP somewhere, probably not on your machine running R. E.g. you can use your ISP's mail server.
    – daroczig
    May 5 '14 at 21:34














  • 1




    It would be awesome know how to solve this problem I always got error trying to use this function @user1471980
    – Duck
    May 1 '14 at 18:08






  • 1




    what's your operating system?
    – Matthew Plourde
    May 1 '14 at 18:25










  • Does mailR work using the same config?
    – lukeA
    May 1 '14 at 18:30










  • You need to set a valid smtpServer and valid email address in to. Not to mention that this is a duplicate stackoverflow.com/questions/2885660/…
    – David Arenburg
    May 1 '14 at 19:15










  • @Duck sure it works on Windows or any other operating system, you just need an SMTP somewhere, probably not on your machine running R. E.g. you can use your ISP's mail server.
    – daroczig
    May 5 '14 at 21:34








1




1




It would be awesome know how to solve this problem I always got error trying to use this function @user1471980
– Duck
May 1 '14 at 18:08




It would be awesome know how to solve this problem I always got error trying to use this function @user1471980
– Duck
May 1 '14 at 18:08




1




1




what's your operating system?
– Matthew Plourde
May 1 '14 at 18:25




what's your operating system?
– Matthew Plourde
May 1 '14 at 18:25












Does mailR work using the same config?
– lukeA
May 1 '14 at 18:30




Does mailR work using the same config?
– lukeA
May 1 '14 at 18:30












You need to set a valid smtpServer and valid email address in to. Not to mention that this is a duplicate stackoverflow.com/questions/2885660/…
– David Arenburg
May 1 '14 at 19:15




You need to set a valid smtpServer and valid email address in to. Not to mention that this is a duplicate stackoverflow.com/questions/2885660/…
– David Arenburg
May 1 '14 at 19:15












@Duck sure it works on Windows or any other operating system, you just need an SMTP somewhere, probably not on your machine running R. E.g. you can use your ISP's mail server.
– daroczig
May 5 '14 at 21:34




@Duck sure it works on Windows or any other operating system, you just need an SMTP somewhere, probably not on your machine running R. E.g. you can use your ISP's mail server.
– daroczig
May 5 '14 at 21:34












6 Answers
6






active

oldest

votes

















up vote
17
down vote



accepted










I just tried it out, and it worked for me.



My only differences were I used <> for the from and to:



from = "<email1@dal.ca>"
to = "<email2@gmail.com>"


and my mail control was different, I used



control=list(smtpServer="ASPMX.L.GOOGLE.COM"))





share|improve this answer





















  • Dear @Sarah do you know if your solution works over Windows and Outlook???
    – Duck
    May 1 '14 at 20:59






  • 2




    I am using Windows (8.1), but I don't use outlook, so I'm not sure about that.
    – Sarah
    May 2 '14 at 1:13










  • Thanks @Sarah maybe do you know how to get smtpServer on Windows
    – Duck
    May 2 '14 at 13:49










  • @Duck What would it mean for R to be able to send mail on Outlook?
    – isomorphismes
    May 12 '15 at 6:28






  • 1




    @Duck The mail can be sent through R xor Outlook; those options are mutually exclusive.
    – isomorphismes
    May 13 '15 at 15:09




















up vote
34
down vote













If you need to be able to use an smtp server with authentication you can use the mailR package.



For example using gmail's smtp server:



library(mailR)
sender <- "SENDER@gmail.com"
recipients <- c("RECIPIENT@gmail.com")
send.mail(from = sender,
to = recipients,
subject = "Subject of the email",
body = "Body of the email",
smtp = list(host.name = "smtp.gmail.com", port = 465,
user.name = "YOURUSERNAME@gmail.com",
passwd = "YOURPASSWORD", ssl = TRUE),
authenticate = TRUE,
send = TRUE)





share|improve this answer



















  • 7




    I recieve such an error: Error in ls(envir = envir, all.names = private) : invalid 'envir' argument
    – Marcin Kosiński
    Mar 15 '15 at 16:46






  • 1




    I cannot replicate your error. The code works for me like it is. Consider asking a new question where you describe how to reproduce this error and probably someone will be able to help you. Maybe this helps.
    – alko989
    Mar 16 '15 at 12:01










  • @MarcinKosinski I got that error as well but then restarted R and it worked for me.
    – isomorphismes
    May 12 '15 at 6:31










  • Worked so far so good for me, using a corporate Google Apps account. Tks.+1
    – Murta
    Nov 27 '15 at 16:14


















up vote
10
down vote













Sorry for bumping up this thread. If you want to send email from R using Microsoft outlook, below is the way to go using the RDCOMClient package. I myself spent a lot of time trying to find an answer on this. I thought it would be useful to have this solution too in this thread for users.



Full credit to @agstudy who provided the original solution in this link - Sending email in R via outlook



library (RDCOMClient)

OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]] = "test@test.com"
outMail[["subject"]] = "Test Subject"
outMail[["body"]] = "Body of email"
outMail$Send()





share|improve this answer






























    up vote
    2
    down vote













    library(mailR)
    sender <- "abc@gmail.com"

    recipients <- c("bcd@gmail.com","xyz@gmail.com")

    send.mail(from = sender, to = recipients, subject="Cash_Collected_Bank_transfer",Sys.Date(),"{}", body = Summary1, encoding = "utf-8",
    smtp = list(host.name = "smtp.gmail.com", port = 465,
    user.name="abc@gmail.com", passwd="abc@1234", ssl=TRUE), authenticate = TRUE, send = TRUE ,attach.files = c(path2),html = TRUE , inline = TRUE )





    share|improve this answer



















    • 2




      Although your answer may be correct, it is preferable to add explanatory text to help readers understand your code.
      – vincentmajor
      Apr 11 '17 at 16:40


















    up vote
    0
    down vote













    There are two ways to send an email via Gmail, anonymized or authenticated. Here is the code for anonymized:



    library(mailR)
    send.mail(from = "sender@gmail.com",
    to = c("Recipient 1 <recipient1@gmail.com>", "recipient2@gmail.com"),
    cc = c("CC Recipient <cc.recipient@gmail.com>"),
    bcc = c("BCC Recipient <bcc.recipient@gmail.com>"),
    subject = "Subject of the email",
    body = "Body of the email",
    smtp = list(host.name = "aspmx.l.google.com", port = 25),
    authenticate = FALSE,
    send = TRUE)


    Make sure the recipient emails are Gmail too. It most likely goes to the spam folder in the Gmail account so make sure to mark it "not spammed".



    You can find more info here.






    share|improve this answer




























      up vote
      0
      down vote













      If you prefer an in-house solution with your server, you can call the linux sendmail.



      EMAIL <- myEmail@gmail.com
      cmd <- 'subject="Info server";body="This is an email"'
      cmd <- paste("echo -e "Subject:${subject}n${body}" | /usr/sbin/sendmail -t "", EMAIL, """)
      system(cmd)





      share|improve this answer





















        Your Answer






        StackExchange.ifUsing("editor", function () {
        StackExchange.using("externalEditor", function () {
        StackExchange.using("snippets", function () {
        StackExchange.snippets.init();
        });
        });
        }, "code-snippets");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "1"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f23412265%2fhow-do-you-send-email-from-r%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        6 Answers
        6






        active

        oldest

        votes








        6 Answers
        6






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        17
        down vote



        accepted










        I just tried it out, and it worked for me.



        My only differences were I used <> for the from and to:



        from = "<email1@dal.ca>"
        to = "<email2@gmail.com>"


        and my mail control was different, I used



        control=list(smtpServer="ASPMX.L.GOOGLE.COM"))





        share|improve this answer





















        • Dear @Sarah do you know if your solution works over Windows and Outlook???
          – Duck
          May 1 '14 at 20:59






        • 2




          I am using Windows (8.1), but I don't use outlook, so I'm not sure about that.
          – Sarah
          May 2 '14 at 1:13










        • Thanks @Sarah maybe do you know how to get smtpServer on Windows
          – Duck
          May 2 '14 at 13:49










        • @Duck What would it mean for R to be able to send mail on Outlook?
          – isomorphismes
          May 12 '15 at 6:28






        • 1




          @Duck The mail can be sent through R xor Outlook; those options are mutually exclusive.
          – isomorphismes
          May 13 '15 at 15:09

















        up vote
        17
        down vote



        accepted










        I just tried it out, and it worked for me.



        My only differences were I used <> for the from and to:



        from = "<email1@dal.ca>"
        to = "<email2@gmail.com>"


        and my mail control was different, I used



        control=list(smtpServer="ASPMX.L.GOOGLE.COM"))





        share|improve this answer





















        • Dear @Sarah do you know if your solution works over Windows and Outlook???
          – Duck
          May 1 '14 at 20:59






        • 2




          I am using Windows (8.1), but I don't use outlook, so I'm not sure about that.
          – Sarah
          May 2 '14 at 1:13










        • Thanks @Sarah maybe do you know how to get smtpServer on Windows
          – Duck
          May 2 '14 at 13:49










        • @Duck What would it mean for R to be able to send mail on Outlook?
          – isomorphismes
          May 12 '15 at 6:28






        • 1




          @Duck The mail can be sent through R xor Outlook; those options are mutually exclusive.
          – isomorphismes
          May 13 '15 at 15:09















        up vote
        17
        down vote



        accepted







        up vote
        17
        down vote



        accepted






        I just tried it out, and it worked for me.



        My only differences were I used <> for the from and to:



        from = "<email1@dal.ca>"
        to = "<email2@gmail.com>"


        and my mail control was different, I used



        control=list(smtpServer="ASPMX.L.GOOGLE.COM"))





        share|improve this answer












        I just tried it out, and it worked for me.



        My only differences were I used <> for the from and to:



        from = "<email1@dal.ca>"
        to = "<email2@gmail.com>"


        and my mail control was different, I used



        control=list(smtpServer="ASPMX.L.GOOGLE.COM"))






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 1 '14 at 18:23









        Sarah

        531414




        531414












        • Dear @Sarah do you know if your solution works over Windows and Outlook???
          – Duck
          May 1 '14 at 20:59






        • 2




          I am using Windows (8.1), but I don't use outlook, so I'm not sure about that.
          – Sarah
          May 2 '14 at 1:13










        • Thanks @Sarah maybe do you know how to get smtpServer on Windows
          – Duck
          May 2 '14 at 13:49










        • @Duck What would it mean for R to be able to send mail on Outlook?
          – isomorphismes
          May 12 '15 at 6:28






        • 1




          @Duck The mail can be sent through R xor Outlook; those options are mutually exclusive.
          – isomorphismes
          May 13 '15 at 15:09




















        • Dear @Sarah do you know if your solution works over Windows and Outlook???
          – Duck
          May 1 '14 at 20:59






        • 2




          I am using Windows (8.1), but I don't use outlook, so I'm not sure about that.
          – Sarah
          May 2 '14 at 1:13










        • Thanks @Sarah maybe do you know how to get smtpServer on Windows
          – Duck
          May 2 '14 at 13:49










        • @Duck What would it mean for R to be able to send mail on Outlook?
          – isomorphismes
          May 12 '15 at 6:28






        • 1




          @Duck The mail can be sent through R xor Outlook; those options are mutually exclusive.
          – isomorphismes
          May 13 '15 at 15:09


















        Dear @Sarah do you know if your solution works over Windows and Outlook???
        – Duck
        May 1 '14 at 20:59




        Dear @Sarah do you know if your solution works over Windows and Outlook???
        – Duck
        May 1 '14 at 20:59




        2




        2




        I am using Windows (8.1), but I don't use outlook, so I'm not sure about that.
        – Sarah
        May 2 '14 at 1:13




        I am using Windows (8.1), but I don't use outlook, so I'm not sure about that.
        – Sarah
        May 2 '14 at 1:13












        Thanks @Sarah maybe do you know how to get smtpServer on Windows
        – Duck
        May 2 '14 at 13:49




        Thanks @Sarah maybe do you know how to get smtpServer on Windows
        – Duck
        May 2 '14 at 13:49












        @Duck What would it mean for R to be able to send mail on Outlook?
        – isomorphismes
        May 12 '15 at 6:28




        @Duck What would it mean for R to be able to send mail on Outlook?
        – isomorphismes
        May 12 '15 at 6:28




        1




        1




        @Duck The mail can be sent through R xor Outlook; those options are mutually exclusive.
        – isomorphismes
        May 13 '15 at 15:09






        @Duck The mail can be sent through R xor Outlook; those options are mutually exclusive.
        – isomorphismes
        May 13 '15 at 15:09














        up vote
        34
        down vote













        If you need to be able to use an smtp server with authentication you can use the mailR package.



        For example using gmail's smtp server:



        library(mailR)
        sender <- "SENDER@gmail.com"
        recipients <- c("RECIPIENT@gmail.com")
        send.mail(from = sender,
        to = recipients,
        subject = "Subject of the email",
        body = "Body of the email",
        smtp = list(host.name = "smtp.gmail.com", port = 465,
        user.name = "YOURUSERNAME@gmail.com",
        passwd = "YOURPASSWORD", ssl = TRUE),
        authenticate = TRUE,
        send = TRUE)





        share|improve this answer



















        • 7




          I recieve such an error: Error in ls(envir = envir, all.names = private) : invalid 'envir' argument
          – Marcin Kosiński
          Mar 15 '15 at 16:46






        • 1




          I cannot replicate your error. The code works for me like it is. Consider asking a new question where you describe how to reproduce this error and probably someone will be able to help you. Maybe this helps.
          – alko989
          Mar 16 '15 at 12:01










        • @MarcinKosinski I got that error as well but then restarted R and it worked for me.
          – isomorphismes
          May 12 '15 at 6:31










        • Worked so far so good for me, using a corporate Google Apps account. Tks.+1
          – Murta
          Nov 27 '15 at 16:14















        up vote
        34
        down vote













        If you need to be able to use an smtp server with authentication you can use the mailR package.



        For example using gmail's smtp server:



        library(mailR)
        sender <- "SENDER@gmail.com"
        recipients <- c("RECIPIENT@gmail.com")
        send.mail(from = sender,
        to = recipients,
        subject = "Subject of the email",
        body = "Body of the email",
        smtp = list(host.name = "smtp.gmail.com", port = 465,
        user.name = "YOURUSERNAME@gmail.com",
        passwd = "YOURPASSWORD", ssl = TRUE),
        authenticate = TRUE,
        send = TRUE)





        share|improve this answer



















        • 7




          I recieve such an error: Error in ls(envir = envir, all.names = private) : invalid 'envir' argument
          – Marcin Kosiński
          Mar 15 '15 at 16:46






        • 1




          I cannot replicate your error. The code works for me like it is. Consider asking a new question where you describe how to reproduce this error and probably someone will be able to help you. Maybe this helps.
          – alko989
          Mar 16 '15 at 12:01










        • @MarcinKosinski I got that error as well but then restarted R and it worked for me.
          – isomorphismes
          May 12 '15 at 6:31










        • Worked so far so good for me, using a corporate Google Apps account. Tks.+1
          – Murta
          Nov 27 '15 at 16:14













        up vote
        34
        down vote










        up vote
        34
        down vote









        If you need to be able to use an smtp server with authentication you can use the mailR package.



        For example using gmail's smtp server:



        library(mailR)
        sender <- "SENDER@gmail.com"
        recipients <- c("RECIPIENT@gmail.com")
        send.mail(from = sender,
        to = recipients,
        subject = "Subject of the email",
        body = "Body of the email",
        smtp = list(host.name = "smtp.gmail.com", port = 465,
        user.name = "YOURUSERNAME@gmail.com",
        passwd = "YOURPASSWORD", ssl = TRUE),
        authenticate = TRUE,
        send = TRUE)





        share|improve this answer














        If you need to be able to use an smtp server with authentication you can use the mailR package.



        For example using gmail's smtp server:



        library(mailR)
        sender <- "SENDER@gmail.com"
        recipients <- c("RECIPIENT@gmail.com")
        send.mail(from = sender,
        to = recipients,
        subject = "Subject of the email",
        body = "Body of the email",
        smtp = list(host.name = "smtp.gmail.com", port = 465,
        user.name = "YOURUSERNAME@gmail.com",
        passwd = "YOURPASSWORD", ssl = TRUE),
        authenticate = TRUE,
        send = TRUE)






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 2 '15 at 13:18

























        answered May 21 '14 at 21:21









        alko989

        4,24732050




        4,24732050








        • 7




          I recieve such an error: Error in ls(envir = envir, all.names = private) : invalid 'envir' argument
          – Marcin Kosiński
          Mar 15 '15 at 16:46






        • 1




          I cannot replicate your error. The code works for me like it is. Consider asking a new question where you describe how to reproduce this error and probably someone will be able to help you. Maybe this helps.
          – alko989
          Mar 16 '15 at 12:01










        • @MarcinKosinski I got that error as well but then restarted R and it worked for me.
          – isomorphismes
          May 12 '15 at 6:31










        • Worked so far so good for me, using a corporate Google Apps account. Tks.+1
          – Murta
          Nov 27 '15 at 16:14














        • 7




          I recieve such an error: Error in ls(envir = envir, all.names = private) : invalid 'envir' argument
          – Marcin Kosiński
          Mar 15 '15 at 16:46






        • 1




          I cannot replicate your error. The code works for me like it is. Consider asking a new question where you describe how to reproduce this error and probably someone will be able to help you. Maybe this helps.
          – alko989
          Mar 16 '15 at 12:01










        • @MarcinKosinski I got that error as well but then restarted R and it worked for me.
          – isomorphismes
          May 12 '15 at 6:31










        • Worked so far so good for me, using a corporate Google Apps account. Tks.+1
          – Murta
          Nov 27 '15 at 16:14








        7




        7




        I recieve such an error: Error in ls(envir = envir, all.names = private) : invalid 'envir' argument
        – Marcin Kosiński
        Mar 15 '15 at 16:46




        I recieve such an error: Error in ls(envir = envir, all.names = private) : invalid 'envir' argument
        – Marcin Kosiński
        Mar 15 '15 at 16:46




        1




        1




        I cannot replicate your error. The code works for me like it is. Consider asking a new question where you describe how to reproduce this error and probably someone will be able to help you. Maybe this helps.
        – alko989
        Mar 16 '15 at 12:01




        I cannot replicate your error. The code works for me like it is. Consider asking a new question where you describe how to reproduce this error and probably someone will be able to help you. Maybe this helps.
        – alko989
        Mar 16 '15 at 12:01












        @MarcinKosinski I got that error as well but then restarted R and it worked for me.
        – isomorphismes
        May 12 '15 at 6:31




        @MarcinKosinski I got that error as well but then restarted R and it worked for me.
        – isomorphismes
        May 12 '15 at 6:31












        Worked so far so good for me, using a corporate Google Apps account. Tks.+1
        – Murta
        Nov 27 '15 at 16:14




        Worked so far so good for me, using a corporate Google Apps account. Tks.+1
        – Murta
        Nov 27 '15 at 16:14










        up vote
        10
        down vote













        Sorry for bumping up this thread. If you want to send email from R using Microsoft outlook, below is the way to go using the RDCOMClient package. I myself spent a lot of time trying to find an answer on this. I thought it would be useful to have this solution too in this thread for users.



        Full credit to @agstudy who provided the original solution in this link - Sending email in R via outlook



        library (RDCOMClient)

        OutApp <- COMCreate("Outlook.Application")
        outMail = OutApp$CreateItem(0)
        outMail[["To"]] = "test@test.com"
        outMail[["subject"]] = "Test Subject"
        outMail[["body"]] = "Body of email"
        outMail$Send()





        share|improve this answer



























          up vote
          10
          down vote













          Sorry for bumping up this thread. If you want to send email from R using Microsoft outlook, below is the way to go using the RDCOMClient package. I myself spent a lot of time trying to find an answer on this. I thought it would be useful to have this solution too in this thread for users.



          Full credit to @agstudy who provided the original solution in this link - Sending email in R via outlook



          library (RDCOMClient)

          OutApp <- COMCreate("Outlook.Application")
          outMail = OutApp$CreateItem(0)
          outMail[["To"]] = "test@test.com"
          outMail[["subject"]] = "Test Subject"
          outMail[["body"]] = "Body of email"
          outMail$Send()





          share|improve this answer

























            up vote
            10
            down vote










            up vote
            10
            down vote









            Sorry for bumping up this thread. If you want to send email from R using Microsoft outlook, below is the way to go using the RDCOMClient package. I myself spent a lot of time trying to find an answer on this. I thought it would be useful to have this solution too in this thread for users.



            Full credit to @agstudy who provided the original solution in this link - Sending email in R via outlook



            library (RDCOMClient)

            OutApp <- COMCreate("Outlook.Application")
            outMail = OutApp$CreateItem(0)
            outMail[["To"]] = "test@test.com"
            outMail[["subject"]] = "Test Subject"
            outMail[["body"]] = "Body of email"
            outMail$Send()





            share|improve this answer














            Sorry for bumping up this thread. If you want to send email from R using Microsoft outlook, below is the way to go using the RDCOMClient package. I myself spent a lot of time trying to find an answer on this. I thought it would be useful to have this solution too in this thread for users.



            Full credit to @agstudy who provided the original solution in this link - Sending email in R via outlook



            library (RDCOMClient)

            OutApp <- COMCreate("Outlook.Application")
            outMail = OutApp$CreateItem(0)
            outMail[["To"]] = "test@test.com"
            outMail[["subject"]] = "Test Subject"
            outMail[["body"]] = "Body of email"
            outMail$Send()






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 13 '17 at 7:39

























            answered Nov 13 '17 at 7:19









            Code_Sipra

            455618




            455618






















                up vote
                2
                down vote













                library(mailR)
                sender <- "abc@gmail.com"

                recipients <- c("bcd@gmail.com","xyz@gmail.com")

                send.mail(from = sender, to = recipients, subject="Cash_Collected_Bank_transfer",Sys.Date(),"{}", body = Summary1, encoding = "utf-8",
                smtp = list(host.name = "smtp.gmail.com", port = 465,
                user.name="abc@gmail.com", passwd="abc@1234", ssl=TRUE), authenticate = TRUE, send = TRUE ,attach.files = c(path2),html = TRUE , inline = TRUE )





                share|improve this answer



















                • 2




                  Although your answer may be correct, it is preferable to add explanatory text to help readers understand your code.
                  – vincentmajor
                  Apr 11 '17 at 16:40















                up vote
                2
                down vote













                library(mailR)
                sender <- "abc@gmail.com"

                recipients <- c("bcd@gmail.com","xyz@gmail.com")

                send.mail(from = sender, to = recipients, subject="Cash_Collected_Bank_transfer",Sys.Date(),"{}", body = Summary1, encoding = "utf-8",
                smtp = list(host.name = "smtp.gmail.com", port = 465,
                user.name="abc@gmail.com", passwd="abc@1234", ssl=TRUE), authenticate = TRUE, send = TRUE ,attach.files = c(path2),html = TRUE , inline = TRUE )





                share|improve this answer



















                • 2




                  Although your answer may be correct, it is preferable to add explanatory text to help readers understand your code.
                  – vincentmajor
                  Apr 11 '17 at 16:40













                up vote
                2
                down vote










                up vote
                2
                down vote









                library(mailR)
                sender <- "abc@gmail.com"

                recipients <- c("bcd@gmail.com","xyz@gmail.com")

                send.mail(from = sender, to = recipients, subject="Cash_Collected_Bank_transfer",Sys.Date(),"{}", body = Summary1, encoding = "utf-8",
                smtp = list(host.name = "smtp.gmail.com", port = 465,
                user.name="abc@gmail.com", passwd="abc@1234", ssl=TRUE), authenticate = TRUE, send = TRUE ,attach.files = c(path2),html = TRUE , inline = TRUE )





                share|improve this answer














                library(mailR)
                sender <- "abc@gmail.com"

                recipients <- c("bcd@gmail.com","xyz@gmail.com")

                send.mail(from = sender, to = recipients, subject="Cash_Collected_Bank_transfer",Sys.Date(),"{}", body = Summary1, encoding = "utf-8",
                smtp = list(host.name = "smtp.gmail.com", port = 465,
                user.name="abc@gmail.com", passwd="abc@1234", ssl=TRUE), authenticate = TRUE, send = TRUE ,attach.files = c(path2),html = TRUE , inline = TRUE )






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 11 '17 at 19:35









                vincentmajor

                768915




                768915










                answered Apr 11 '17 at 13:56









                Piyush Sharma

                211




                211








                • 2




                  Although your answer may be correct, it is preferable to add explanatory text to help readers understand your code.
                  – vincentmajor
                  Apr 11 '17 at 16:40














                • 2




                  Although your answer may be correct, it is preferable to add explanatory text to help readers understand your code.
                  – vincentmajor
                  Apr 11 '17 at 16:40








                2




                2




                Although your answer may be correct, it is preferable to add explanatory text to help readers understand your code.
                – vincentmajor
                Apr 11 '17 at 16:40




                Although your answer may be correct, it is preferable to add explanatory text to help readers understand your code.
                – vincentmajor
                Apr 11 '17 at 16:40










                up vote
                0
                down vote













                There are two ways to send an email via Gmail, anonymized or authenticated. Here is the code for anonymized:



                library(mailR)
                send.mail(from = "sender@gmail.com",
                to = c("Recipient 1 <recipient1@gmail.com>", "recipient2@gmail.com"),
                cc = c("CC Recipient <cc.recipient@gmail.com>"),
                bcc = c("BCC Recipient <bcc.recipient@gmail.com>"),
                subject = "Subject of the email",
                body = "Body of the email",
                smtp = list(host.name = "aspmx.l.google.com", port = 25),
                authenticate = FALSE,
                send = TRUE)


                Make sure the recipient emails are Gmail too. It most likely goes to the spam folder in the Gmail account so make sure to mark it "not spammed".



                You can find more info here.






                share|improve this answer

























                  up vote
                  0
                  down vote













                  There are two ways to send an email via Gmail, anonymized or authenticated. Here is the code for anonymized:



                  library(mailR)
                  send.mail(from = "sender@gmail.com",
                  to = c("Recipient 1 <recipient1@gmail.com>", "recipient2@gmail.com"),
                  cc = c("CC Recipient <cc.recipient@gmail.com>"),
                  bcc = c("BCC Recipient <bcc.recipient@gmail.com>"),
                  subject = "Subject of the email",
                  body = "Body of the email",
                  smtp = list(host.name = "aspmx.l.google.com", port = 25),
                  authenticate = FALSE,
                  send = TRUE)


                  Make sure the recipient emails are Gmail too. It most likely goes to the spam folder in the Gmail account so make sure to mark it "not spammed".



                  You can find more info here.






                  share|improve this answer























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    There are two ways to send an email via Gmail, anonymized or authenticated. Here is the code for anonymized:



                    library(mailR)
                    send.mail(from = "sender@gmail.com",
                    to = c("Recipient 1 <recipient1@gmail.com>", "recipient2@gmail.com"),
                    cc = c("CC Recipient <cc.recipient@gmail.com>"),
                    bcc = c("BCC Recipient <bcc.recipient@gmail.com>"),
                    subject = "Subject of the email",
                    body = "Body of the email",
                    smtp = list(host.name = "aspmx.l.google.com", port = 25),
                    authenticate = FALSE,
                    send = TRUE)


                    Make sure the recipient emails are Gmail too. It most likely goes to the spam folder in the Gmail account so make sure to mark it "not spammed".



                    You can find more info here.






                    share|improve this answer












                    There are two ways to send an email via Gmail, anonymized or authenticated. Here is the code for anonymized:



                    library(mailR)
                    send.mail(from = "sender@gmail.com",
                    to = c("Recipient 1 <recipient1@gmail.com>", "recipient2@gmail.com"),
                    cc = c("CC Recipient <cc.recipient@gmail.com>"),
                    bcc = c("BCC Recipient <bcc.recipient@gmail.com>"),
                    subject = "Subject of the email",
                    body = "Body of the email",
                    smtp = list(host.name = "aspmx.l.google.com", port = 25),
                    authenticate = FALSE,
                    send = TRUE)


                    Make sure the recipient emails are Gmail too. It most likely goes to the spam folder in the Gmail account so make sure to mark it "not spammed".



                    You can find more info here.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Sep 13 at 19:43









                    Habib Karbasian

                    4818




                    4818






















                        up vote
                        0
                        down vote













                        If you prefer an in-house solution with your server, you can call the linux sendmail.



                        EMAIL <- myEmail@gmail.com
                        cmd <- 'subject="Info server";body="This is an email"'
                        cmd <- paste("echo -e "Subject:${subject}n${body}" | /usr/sbin/sendmail -t "", EMAIL, """)
                        system(cmd)





                        share|improve this answer

























                          up vote
                          0
                          down vote













                          If you prefer an in-house solution with your server, you can call the linux sendmail.



                          EMAIL <- myEmail@gmail.com
                          cmd <- 'subject="Info server";body="This is an email"'
                          cmd <- paste("echo -e "Subject:${subject}n${body}" | /usr/sbin/sendmail -t "", EMAIL, """)
                          system(cmd)





                          share|improve this answer























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            If you prefer an in-house solution with your server, you can call the linux sendmail.



                            EMAIL <- myEmail@gmail.com
                            cmd <- 'subject="Info server";body="This is an email"'
                            cmd <- paste("echo -e "Subject:${subject}n${body}" | /usr/sbin/sendmail -t "", EMAIL, """)
                            system(cmd)





                            share|improve this answer












                            If you prefer an in-house solution with your server, you can call the linux sendmail.



                            EMAIL <- myEmail@gmail.com
                            cmd <- 'subject="Info server";body="This is an email"'
                            cmd <- paste("echo -e "Subject:${subject}n${body}" | /usr/sbin/sendmail -t "", EMAIL, """)
                            system(cmd)






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 19 at 19:07









                            Xavier Prudent

                            495522




                            495522






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f23412265%2fhow-do-you-send-email-from-r%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Wiesbaden

                                Marschland

                                Dieringhausen