Reputation: 11
So i am working on a project to automatically send e-mails with an attachment. the subject has to have a specific name but up till now i cannot get the last part to work.
Private WithEvents Mail As Outlook.MailItem
Private WithEvents Inspectors As Outlook.Inspectors
Private Sub Application_Startup()
Set Inspectors = Application.Inspectors
End Sub
Private Sub Inspectors_NewInspector(ByVal Inspector As Inspector)
If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
Set Mail = Inspector.CurrentItem
End If
End Sub
Private Sub Mail_AttachmentAdd(ByVal Attachment As Attachment)
Mail.subject = "[ediDocManager CON TOR " + Attachment.DisplayName
if i run this code i will get as subject ""[ediDocManager CON TOR " + Attachment.DisplayName.pdf" but i want the pdf to be replaced with a"]"
how do i get this done?
Upvotes: 1
Views: 135
Reputation: 761
In VBA you concatenate strings using &
sign not +
. And you can use Replace
function for the PDF part.
Try this:
Mail.subject = "[ediDocManager CON TOR " & Replace(Attachment.DisplayName, "pdf", "]")
Hope this helps!
Upvotes: 1