logo elektroda
logo elektroda
X
logo elektroda

Linking Outlook Footer Information to a Macro for Client Emailing in Excel VBA

kwitu86 9207 7
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 15352027
    kwitu86
    Level 10  
    hi,

    is it possible to attach information from the outlook footer to the macro that sends an e-mail to the client from excel? (instead of the one that takes data from the Contact Details tab)

    Code: VBScript
    Log in, to see the code
  • ADVERTISEMENT
  • #2 15352077
    kinggustav
    Level 27  
    In the mail handling object there is a second .HTMLBody field for the content of the email in HTML.
    After creating the email, there is a signature (if Outlook is supposed to add it). Experts advise to do .HTMLBody = your_content & .HTMLBody. Practically there are problems with it, it does not want to work.
    And by the way, can anyone suggest a nice way to deliver large, heavily formatted content to an email? I tried as an HTML file. It works, but it's kind of... ugly.
  • ADVERTISEMENT
  • #3 15354127
    kwitu86
    Level 10  
    Well, somehow it doesn't want to work for me when I change the language.

    with .HTMLBody = Message & .HTMLBody

    Any ideas for a solution?
  • ADVERTISEMENT
  • #4 15354627
    clubs
    Level 38  
    Hello

    If you have a footer saved in Outlook, do this

    Code: VB.net
    Log in, to see the code
  • #5 15356180
    kinggustav
    Level 27  
    But ... you haven't used this Message anywhere?
  • ADVERTISEMENT
  • #6 15358486
    clubs
    Level 38  
    kinggustav wrote:
    But ... you haven't used this Message anywhere?


    Kwitu86 wrote that he wanted to use only Outlook instead of the contact details tab
  • #7 15364890
    Michal_Dabrowski
    Level 2  
    Hello,

    Everything goes as you want ;)

    You do it like this:

    1. As they wrote above, in the procedure that sends an email, you must have the content entered as HTMLBody (instead of Body)

    2. You have to cram into the directory where you have your Outlook signatures and then "suck" the specific signature with the HTML code

    3. The sucked code must be added to the content of the email in the sending procedure

    Okay, now the specifics:
    ad1.
    I think it's simple here :) changing .Body to .HTMLBody :P

    ad2.

    I recommend doing it with Environ (because the signatures are in the directory depending on the username in the system), that is

    
    c:\users\ tutaj_twoja_nazwa_usera \AppData\Roaming\Microsoft\Podpisy\i_tutaj_nazwa_twojego_podpisu.htm
    


    !!!CAUTION!!! check this path at home because I don't remember now why but sometimes instead of the Signatures directory, some have the Signatures directory so then it will be of course:

    
    c:\users\ tutaj_twoja_nazwa_usera \AppData\Roaming\Microsoft\Signatures\i_tutaj_nazwa_twojego_podpisu.htm
    


    Okay, everyone has a different username, so when I do something like this with people on training, we use Environ here. So in the end it would look like this:

    
    sciezka = Environ("USERPROFILE") & "\AppData\Roaming\Microsoft\Podpisy\" & podpisek & ".htm"


    Ok, the path to the signature is there, now we're downloading HTMLA from it.

    We have several options here, but probably the simplest will be the readall function built into the TextStreem object from the scrrun.dll library (it's cool, it's Windows, so everyone has it, so do you ;) we can add this biblio through early or late binding (but that's a topic for another post ;)

    Code: VB.net
    Log in, to see the code


    There may still be problems with images if you have them in the footer (especially when we have several footers and the macro is to decide which one to add to the email when). If you write it like this, I'll be happy to help :)


    Regards
    Michal Dabrowski
  • #8 15370382
    kwitu86
    Level 10  
    hi,

    In fact, everything can be done as you describe.

    I did it a bit on a whim:

    Code: VBScript
    Log in, to see the code


    where I changed the frame settings from the center to the left side of the email

    Code: VBScript
    Log in, to see the code


    but I will be sure to check the solution presented above :)

Topic summary

The discussion revolves around integrating Outlook footer information into an Excel VBA macro for sending emails. Users explore the possibility of using the HTMLBody property to include Outlook signatures in the email content. Solutions involve creating an Outlook application object, retrieving the signature from the user's signature directory, and appending it to the email body. Key steps include ensuring the email is formatted as HTML and handling potential errors during the process. Various users share code snippets and troubleshooting tips to achieve the desired functionality.
Summary generated by the language model.
ADVERTISEMENT