Consulting

Results 1 to 5 of 5

Thread: Insert Text in EVERY email using VBA

  1. #1
    VBAX Regular
    Joined
    Mar 2014
    Posts
    11
    Location

    Insert Text in EVERY email using VBA

    What I want to do is insert text in the body of EVERY email that gets sent. I dont want a signture, I want this to be spereate. So example:When I start an email, the body with already have something in it. Such as an ID #....... I'm trying to track every email by giving each terminal an ID #..... Please help and let me know if you need more info. Thanks,Brandon

  2. #2
    the simplest solution does not involve VBA, just add to the message form design

    to do by vba, probably the only solution to automate, is to add the #ID as the message is sent

    Private Sub Application_ItemSend(ByVal item As Object, Cancel As Boolean)
    item.Body = "Terminal #77" & vbNewLine & item.Body
    End Sub
    you could store the terminal number, so that it can be returned for each terminal instead of hard coding, then the same code can work for all terminals
    also you may need to use the htmlbody, if the messages are fromatted as html

  3. #3
    VBAX Regular
    Joined
    Mar 2014
    Posts
    11
    Location
    Quote Originally Posted by westconn1 View Post
    the simplest solution does not involve VBA, just add to the message form designto do by vba, probably the only solution to automate, is to add the #ID as the message is sent
    Private Sub Application_ItemSend(ByVal item As Object, Cancel As Boolean)item.Body = "Terminal #77" & vbNewLine & item.BodyEnd Sub
    you could store the terminal number, so that it can be returned for each terminal instead of hard coding, then the same code can work for all terminalsalso you may need to use the htmlbody, if the messages are fromatted as html
    here is my code now to Auto BCC.... Can you please explain how I would put this in to use the #ID? I'm not very good at VBA and need details on how to enter it LOL..>Sorry.>Trying to learn!..................................................................... ....................Private Sub Application_ItemSend(ByVal item As Object, _Cancel As Boolean)Dim objRecip As RecipientDim strMsg As StringDim res As IntegerDim strBcc As StringOn Error Resume NextIf item.SentOnBehalfOfName = "Mailbox" ThenstrBcc = "Mailbox"End IfSet objRecip = item.Recipients.Add(strBcc)objRecip.Type = olBCCIf Not objRecip.Resolve ThenIf res = vbNo ThenCancel = TrueSet objRecip = NothingEnd Sub

  4. #4
    just put it on the second or third lines, i can not really tell with the way your code has come out

    Private Sub Application_ItemSend(ByVal item As Object, Cancel As Boolean)
    
    Dim objRecip As Recipient
    Dim strMsg As String
    Dim res As Integer
    Dim strBcc As String
    'On Error Resume Next
    item.Body = "Terminal #77" & vbNewLine & item.Body
    If item.SentOnBehalfOfName = "Mailbox" Then
        strBcc = "Mailbox"
        Set objRecip = item.Recipients.Add(strBcc)
        objRecip.Type = olBCC
        If Not objRecip.Resolve Then Cancel = True
    ''    If res = vbNo Then
        Set objRecip = Nothing
    End If
    End Sub
    i changed your code a bit see if it works

  5. #5
    VBAX Regular
    Joined
    Mar 2014
    Posts
    11
    Location
    AMAZING! Thank you very much! Works like a charm!

Tags for this Thread

Posting Permissions

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