开发者

VBA form mailto hyperlink ouput to client question

I have a form looking up email addresses in an excel sheet, which works fine in creating mailto hyperlinks. they look like this...

VBA form mailto hyperlink ouput to client question

But I would like to show the person's actual name, like this, and I have the string available...

VBA form mailto hyperlink ouput to client question

My question is whether this can be done in the way the link is constructed, or is this something the email client is doing by matching from the address book? I would prefer to train the address book, rather than create email only addresses.

additionally here is a sampl开发者_开发技巧e of what I have

Link = "mailto:" & EmpForm.Label10
whoTo = EmpForm.TextBox3 'which I want to use in the TO:whoever
ActiveWorkbook.FollowHyperlink Address:=Link, NewWindow:=True


Instead of following the link from Excel, meaningly, remove this part:

ActiveWorkbook.FollowHyperlink Address:=Link, NewWindow:=True

You could create a mail from Excel. Thus, you could set the parameters you want.
Here is a sample of code (found here):

' requires a reference to the Microsoft Outlook 8.0 Object Library    
Sub SendAnEmailWithOutlook()
' creates and sends a new e-mail message with Outlook
Dim OLF As Outlook.MAPIFolder, olMailItem As Outlook.MailItem
Dim ToContact As Outlook.Recipient
    Set OLF = GetObject("", _
        "Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    Set olMailItem = OLF.Items.Add ' creates a new e-mail message
    With olMailItem
        .Subject = "Subject for the new e-mail message" ' message subject
        Set ToContact = .Recipients.Add("name@domain.com") ' add a recipient
        Set ToContact = .Recipients.Add("name@company.com") ' add a recipient
        ToContact.Type = olCC ' set latest recipient as CC
        Set ToContact = .Recipients.Add("name@org.net") ' add a recipient
        ToContact.Type = olBCC ' set latest recipient as BCC
        .Body = "This is the message text" & Chr(13) 
        ' the message text with a line break
        .Attachments.Add "C:\FolderName\Filename.txt", olByValue, , _
            "Attachment" ' insert attachment
'        .Attachments.Add "C:\FolderName\Filename.txt", olByReference, , _
             "Shortcut to Attachment" ' insert shortcut
'        .Attachments.Add "C:\FolderName\Filename.txt", olEmbeddedItem, , _
             "Embedded Attachment" ' embedded attachment
'        .Attachments.Add "C:\FolderName\Filename.txt", olOLE, , _
             "OLE Attachment" ' OLE attachment
        .OriginatorDeliveryReportRequested = True ' delivery confirmation
        .ReadReceiptRequested = True ' read confirmation
        '.Save ' saves the message for later editing
        .Send ' sends the e-mail message (puts it in the Outbox)
    End With
    Set ToContact = Nothing
    Set olMailItem = Nothing
    Set OLF = Nothing
End Sub

To create your recipient field, you can use:

arrTo = Split(whoTo,"@")
whoTo = UCase(arrTo[0]) & " " & UCase(arrTo[1]) & "<" & whoTo & ">"


Outlook new mail window will show you name if the e-mail address you are mailing to is present in it's address book else full e-mail address is shown.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜