Merge branch '6.1.x'

This commit is contained in:
Brian Clozel
2024-09-13 10:21:43 +02:00
2 changed files with 24 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,6 +43,7 @@ import org.springframework.core.io.InputStreamSource;
import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.MimeTypeUtils;
/**
* Helper class for populating a {@link jakarta.mail.internet.MimeMessage}.
@@ -995,7 +996,8 @@ public class MimeMessageHelper {
*/
public void addInline(String contentId, Resource resource) throws MessagingException {
Assert.notNull(resource, "Resource must not be null");
String contentType = getFileTypeMap().getContentType(resource.getFilename());
String contentType = (resource.getFilename() != null ?
getFileTypeMap().getContentType(resource.getFilename()) : MimeTypeUtils.APPLICATION_OCTET_STREAM_VALUE);
addInline(contentId, resource, contentType);
}