+ Reply to Thread
Results 1 to 7 of 7

Adding Signature to eamil using VBA

Hybrid View

Shades1970 Adding Signature to eamil... 03-01-2019, 06:44 AM
KOKOSEK Re: Adding Signature to eamil... 03-01-2019, 07:25 AM
Shades1970 Re: Adding Signature to eamil... 03-26-2019, 05:42 AM
KOKOSEK Re: Adding Signature to eamil... 03-26-2019, 08:19 AM
Shades1970 Re: Adding Signature to eamil... 04-01-2019, 08:11 AM
jmac1947 Re: Adding Signature to eamil... 04-03-2019, 12:27 AM
Shades1970 Re: Adding Signature to eamil... 04-08-2019, 05:08 PM
  1. #1
    Registered User
    Join Date
    02-17-2017
    Location
    Cornwall, England
    MS-Off Ver
    2016
    Posts
    23

    Angry Adding Signature to eamil using VBA

    Hi all

    I have a worksheet that users can send a copy to an individualise it adds the body text and I want to add the signature but it does not do it my code is as follow any help would be very much appreciated many thanks. As I have said this all work apart from adding the signature I have looked as so many forum and I just cant get it to add the body text and signature it always seems to be one or the other.

    Private Sub EmailButton1_Click()
        'Do not forget to change the email ID
        'before running this code
    
        Dim OlApp As Object
        Dim NewMail As Object
        Dim TempFilePath As String
        Dim FileExt As String
        Dim TempFileName As String
        Dim FileFullPath As String
        Dim FileFormat As Variant
        Dim Wb1 As Workbook
        Dim Wb2 As Workbook
        Dim Signature As String
    
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
        End With
        Set Wb1 = ThisWorkbook
        ActiveSheet.Copy
        Set Wb2 = ActiveWorkbook
    
        'Below code will get the File Extension and
        'the file format which we want to save the copy
        'of the workbook with the active sheet.
    
        With Wb2
            If Val(Application.Version) < 12 Then
                 FileExt = ".xls": FileFormat = -4143
            Else
                Select Case Wb1.FileFormat
                Case 51: FileExt = ".xlsx": FileFormat = 51
                Case 52:
                    If .HasVBProject Then
                        FileExt = ".xlsm": FileFormat = 52
                    Else
                        FileExt = ".xlsx": FileFormat = 51
                    End If
                Case 56: FileExt = ".xls": FileFormat = 56
                Case Else: FileExt = ".xlsb": FileFormat = 50
                End Select
            End If
        End With
    
        'Save your workbook in your temp folder of your system
        'below code gets the full path of the temporary folder
        'in your system
    
        TempFilePath = Environ$("temp") & "\"
    
        'Now append a date and time stamp
        'in your new file
    
        TempFileName = "FMT 103" & "-" & Format(Now, "dd-mmm-yy")
    
        'Complete path of the file where it is saved
        FileFullPath = TempFilePath & TempFileName & FileExt
    
        'Now save your currect workbook at the above path
        Wb2.SaveAs FileFullPath, FileFormat:=FileFormat
    
        'Now open a new mail
    
        Set OlApp = CreateObject("Outlook.Application")
        Set NewMail = OlApp.CreateItem(0)
    
        On Error Resume Next
        With NewMail
            .To = ""
            .CC = ""
            .BCC = ""
            .Subject = "Resign for MT Order on F/MT 103"
            .Body = "Hello, you are required to resign MT Order" & vbCrLf & vbCrLf & _
            "MT Orders are re-signed annually on the F/MT 103." & vbCrLf & _
            "Print F/MT 103 and sign." & vbCrLf & _
            "You are also required to produce a new Driving Licence (DL) Summary Sheet form" & vbCrLf & _
            "Click on Start now." & vbCrLf & _
            "Enter DL No, National Insurance No, & Post Code (That is on your DL)." & vbCrLf & _
            "Click I agree in the declaration box." & vbCrLf & _
            "Click View now." & vbCrLf & _
            "Click Get you check code tab for right." & vbCrLf & _
            "Click Get a code." & vbCrLf & _
            "Click Print or save a driving summary." & vbCrLf & _
            "Click open and print this page." & vbCrLf & vbCrLf & _
            "(This is also required for the old-style paper licences)." & vbCrLf & _
            "If your High Way Code Test (HWCT) date has expired, you can undertake a new test at the following web address." & vbCrLf & _
            "On completion of test print a sign." & vbCrLf & _
            "Scan all signed document along with DL card Front & Back and send to Wing HQ for processing." & vbCrLf & vbCrLf & _
            "Many Thanks" & vbCrLf & vbCrLf & Signature
            .Attachments.Add FileFullPath '--- full path of the temp file where it is saved
            .Display
            '.Send   'or use .Display to show you the email before sending it.
        End With
        On Error GoTo 0
    
        'Since mail has been sent with the attachment
        'Now close and delete the temp file from the
        'temp folder
        Wb2.Close savechanges:=False
        Kill FileFullPath
    
        'set nothing to the objects created
        Set NewMail = Nothing
        Set OlApp = Nothing
    
        'Now set the application properties back to true
        With Application
            .ScreenUpdating = True
            .EnableEvents = True
        End With
    
    End Sub

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: Adding Signature to eamil using VBA

    It looks like it is ready to add signature here:

           "Many Thanks" & vbCrLf & vbCrLf & Signature
    so before:

    'Now open a new mail
    set signature like this:

    Signature="You forename and name or something else"
    or, if you want to change it dynamically (for serial mailing, or something), like this:
    Signature = range("B10").value
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Registered User
    Join Date
    02-17-2017
    Location
    Cornwall, England
    MS-Off Ver
    2016
    Posts
    23

    Re: Adding Signature to eamil using VBA

    Sorry but I do not understand I am needing the signature of the person that is going to be sending this email which my change from one user to an other so need to add their default signature block many thanks

  4. #4
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: Adding Signature to eamil using VBA

    As I said on previous post is ready here:

       "Many Thanks" & vbCrLf & vbCrLf & Signature
    if you want to use standard set signature try this (of course earlier in a code):

    'GET DEFAULT EMAIL SIGNATURE
        signature = Environ("appdata") & "\Microsoft\Signatures\"
        If Dir(signature, vbDirectory) <> vbNullString Then
            signature = signature & Dir$(signature & "*.htm")
        Else:
            signature = ""
        End If
        signature = CreateObject("Scripting.FileSystemObject").GetFile(signature).OpenAsTextStream(1, -2).ReadAll

  5. #5
    Registered User
    Join Date
    02-17-2017
    Location
    Cornwall, England
    MS-Off Ver
    2016
    Posts
    23

    Re: Adding Signature to eamil using VBA

    I am sorry this did not work just ended up with a lot of code added to the email

  6. #6
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Adding Signature to eamil using VBA

    I am a little confused as to what exactly you mean by "signature"?

    Seems to be multiple options ranging from a simple text string of the actual user name who is creating the email through to a more complex "email signature block" of multiple lines of string text and eventually to an image that contains a "real signature" and contact details, again for the user actually creating the email.

    Each of these will need a different solution, at least that is what it looks like to me.

    AND... as I am sure you have seen from other posts, it always helps you get an answer if you attach a sample workbook to you request.
    Cheers

    Cheers

    Jmac1947

    1. Please consider clicking on the * Add Reputation if you think this post has helped you
    2. Mark your thread as SOLVED when question is resolved

  7. #7
    Registered User
    Join Date
    02-17-2017
    Location
    Cornwall, England
    MS-Off Ver
    2016
    Posts
    23

    Re: Adding Signature to eamil using VBA

    Signature is the outlook signature block

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA, Eamil and signature
    By TheRockHolger in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2017, 11:58 AM
  2. Replies: 3
    Last Post: 04-15-2015, 09:34 PM
  3. Adding a digital signature
    By vixim in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 0
    Last Post: 06-17-2014, 03:17 PM
  4. Adding Signature in Email through VBA issue
    By naveenmarapaka in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 09-24-2012, 05:30 AM
  5. adding Signature to charts
    By sbueso in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-03-2012, 09:29 AM
  6. Adding Signature to send mail
    By nick_s in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2010, 12:47 PM
  7. [SOLVED] Eamil formatting
    By raf53 in forum Excel General
    Replies: 3
    Last Post: 03-31-2005, 07:26 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1