Mail from Excel VBA RRS feed

  • Question

  • Fellow sufferers

    I am trying to mail (within our intranet) from Excel VBA; it is a report that when generated should just mail an OK status, just a very simple mail without any attachments. I was told, there is a mail server on our intranet which allows easy mailing, it is called smtp.feen.dk.. The administrator says, there is no login to this particular server (but then you can only mail within the intranet). All I need, is the string "smtp.feen.dk", they say.

    Any idea, how I structure my VBA code?

    Thanks in advance!
    Friday, November 1, 2013 4:38 PM

All replies

  • I would try posting your question to the Excel for Developers forum, or perhaps a moderator can move it there:


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Friday, November 1, 2013 6:50 PM

    Hi Peter,

    You can use the below code. It uses the System SMTP server to trigger the mail. Also please make sure your SMTP services are running.

    CODE :

    Set myMail = CreateObject("CDO.Message")
        myMail.Subject = "XXXXXX"
        myMail.from = "X@X.com"
        myMail.To = "X@X.com,Y@X.com"
        myMail.CC = "X@X.com"
    ' if you want the attachment you can use the below line of code 
        myMail.AddAttachment ("C:\XXXXXX\XXXXX\XXXXX\XXXX.xls")
        emailbody = "Hello Reader,<br><br>you can put the email body here"
        myMail.HTMLBody = emailbody

        Set myMail = Nothing

    Tuesday, November 5, 2013 3:54 AM
  • Peter gives to you way to send email without Email client (but you should to have email account).

    If this way is good for you, then take look on this article.

    Oskar Shon, Office System MVP - www.VBATools.pl
    if Helpful; Answer when a problem solved

    Tuesday, November 19, 2013 2:46 PM